【问题标题】:SOAP request in Node using SSL使用 SSL 的 Node 中的 SOAP 请求
【发布时间】:2018-06-03 22:31:33
【问题描述】:

最近,我一直在处理 SOAP 请求。

我已经设法使用 node-soap 模块向 http 服务发送成功的请求。但是,现在我想用它向外部 https 网络服务发送请求。

我已经设法使用带有 cUrl 的 .cer 文件发送 SSL 请求。但是在 node.js 代码中尝试这个时,我遇到了错误。根据我阅读的内容(请参阅 node-soap 模块上的ClientSSLSecurity),我需要一个密钥(.key 格式)和一个证书(.pem 格式)。我不知道这是否需要私钥?我已经设法从我的 .cer 文件中提取了一个公钥。

我试过下面的代码:

var createSoapClient = function (){
    soap.createClient(url, function(err,client){
        client.setSecurity(new soap.ClientSSLSecurity(
            'mycert.cer',
            'pubkey.key'
        ));
        if(err)
            console.error(err);
        else {
            client.MyOperation(args,function(err,response){
                if(err){
                    console.error(err);
                }
                else{
                    console.log(response);
                }
            })
        }
    });
}

但是,这会导致以下错误消息:

Error: error:0906D06C:PEM routines:PEM_read_bio:no start line

我错过了什么?是私钥吗?

谢谢!

【问题讨论】:

    标签: node.js web-services ssl curl soap


    【解决方案1】:

    根据在 npm 上找到的包,关于 ClientSSLSecurity :

    https://www.npmjs.com/package/axl-node-soap
    https://www.npmjs.com/package/soap-x509
    https://www.npmjs.com/package/strong-soap#clientsslsecurity
    https://www.npmjs.com/package/soap#clientsslsecurity
    

    我假设您向 ClientSSLSecurity 传递了错误的参数。似乎先是先是密钥,然后是证书,你是在传递先是证书,然后是密钥

    尝试做这样的事情:

       client.setSecurity(new soap.ClientSSLSecurity(
            'pubkey.key',
            'mycert.cer'
    
        ));
    

    你用的是哪个包?


    你的情侣密钥/证书可能是错误的

    尝试重新生成证书:

    openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem
    openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out server.crt
    

    然后传递 key.pem 作为密钥和 server.crt 作为证书。

    【讨论】:

    • 不幸的是,同样的错误,我正在使用 node-soap 模块link
    猜你喜欢
    • 1970-01-01
    • 2020-10-18
    • 1970-01-01
    • 2019-02-08
    • 1970-01-01
    • 1970-01-01
    • 2018-09-29
    • 2023-03-17
    • 1970-01-01
    相关资源
    最近更新 更多