使用Node.js调用需要证书的SOAP服务

时间:2018-12-24 20:00:53

标签: node.js soap wsdl ssl-certificate client-certificates

Nodejs SOAP客户端抛出错误[ERR_TLS_CERT_ALTNAME_INVALID]:主机名/ IP与证书的altname不匹配:

我试图在nodejs中使用soap来调用SOAP服务。但是我收到错误 [ERR_TLS_CERT_ALTNAME_INVALID]:主机名/ IP与证书的替代名称不匹配:IP:XXX.XXX.XXX.XXX不在证书的列表中:。我是nodejs的新手,不确定如何调用需要来自nodejs的证书的SOAP服务。还欢迎使用其他方法调用需要Nodejs中的证书的SOAP服务。

var url = "https://soapserviceurl?wsdl";

soap.createClient(url, function (err, client) { 
    if (err) {
        console.log("Error Occurred!!");
        console.log(err);       
    }
    else {
        console.log(client.describe());
    }
});

1 个答案:

答案 0 :(得分:0)

请尝试

class EditContactScreen extends StatelessWidget {
  final bloc = EditContactScreenBloc();
  final Contact contact;

  EditContactScreen({this.contact});

  @override
  Widget build(BuildContext context) {
    final globalBloc = GlobalProvider.of(context);

    return Column(
      children: <Widget>[
        TextField(onChanged: (firstName) => bloc.updateContact(contact.copyWith(firstName: firstName))),
        TextField(onChanged: (lastName) => bloc.updateContact(contact.copyWith(firstName: lastName))),
        TextField(onChanged: (phoneNumber) => bloc.updateContact(contact.copyWith(firstName: phoneNumber))),
        RaisedButton(child: Text('Update'), onPressed: () async {
          await bloc.update();
          await globalBloc.refreshContacts();
          Navigator.of(context).pop();
        },)
      ],
    );
  }
}
或:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0" //this is insecure 

或者:

    var soap = require('soap'),
        request = require('request'),
        fs = require('fs');

    var url = "https://soapserviceurl?wsdl";
    
    var req = request.defaults({
       strictSSL: false
    );

    soap.createClient(url, { 
            request : req
    }, function(err, client) {
    	//your code
    });