SOAP有两个证书文件和"无法连接到主机"

时间:2016-11-11 15:40:15

标签: php ssl soap certificate php-openssl

我在将PHP与需要使用SSL证书的API连接时遇到问题。问题是当我运行我的PHP代码时,我得到了#34;无法连接到主机"。

我能够使用CURL连接到服务提供商,如下所示:

module.exports = function(config) {
  config.set({

    basePath: '',

    frameworks: ['jasmine'],

    files: [
      // Polyfills.
      'node_modules/es6-shim/es6-shim.js',

      // .. more files such as reflect, systemjs, zones, rxjs ...

      // load typescript as well !!!!!!!!!!!!!!!!!!!!!!!
      { pattern: 'node_modules/typescript/**/*.js', included: false, watched: false },
      { pattern: 'node_modules/typescript/**/*.js.map', included: false, watched: false },

      { pattern: 'karma-test-shim.js', included: true, watched: true},
	  
      // load angular and your own code

    ],

    // proxied base paths
    proxies: {
      // required for component assests fetched by Angular's compiler
      "/dist/": "/base/dist/"
    },

	// karma config ...
	
    singleRun: false
  })
}

但是,我无法使用SOAP执行此操作:

// Load our SystemJS configuration.

System.config({
    baseURL: '/base'
});

System.config(
    {
        // set the transpiler here !!!!!
        transpiler: 'typescript',
        paths: {
            // paths serve as alias
            'npm:': 'node_modules/'
        },
        map: {
            'dist': 'dist',
			
            // mapping for typescript !!!!!!!!!!!!!
            'typescript': 'npm:typescript/lib/typescript.js',
			
            // ... more mappings
			
            // other libraries
            'rxjs': 'npm:rxjs'
        },
        packages: {
            'dist': {
                defaultExtension: 'js'
            },
            'rxjs': {
                defaultExtension: 'js'
            }
        }
    });

Promise.all([
    System.import('@angular/core/testing'),
    System.import('@angular/platform-browser-dynamic/testing')
]).then(function (providers) {
	// ...
}).then(function() {
	// ...
}).then(__karma__.start, __karma__.error);

导致"无法连接到主机"。

问题可能出在证书本身,也许我需要在一个文件中合并两个证书。我可以看到很多人都有同样的问题,他们中的大多数都没有得到答案。

为什么SOAP代码返回"无法连接到主机",我该如何解决?

2 个答案:

答案 0 :(得分:0)

有些地方可以开始:

1)certificate.crt究竟是什么?它是客户端证书还是CA证书?您正在使用CURLOPT_SSLCERT(设置客户端证书),但正在使用' cafile' SoapClient中的file指令(设置CA证书文件)。

2)您使用的是CURLOPT_SSL_VERIFYPEER = false,但在其他代码段中您使用的是verify_peer。

因此,请尝试使用相同类型的环境进行更多调试。

答案 1 :(得分:0)

如果您的证书是自签名的,则不必设置cafile。 cafile仅适用于CA连锁店。 local_cert需要同时具有:证书(叶子)和连接的私钥,例如:

-----BEGIN CERTIFICATE-----  
MIIDsDCCApgCAWUwDQ....  
-----END CERTIFICATE-----  
-----BEGIN RSA PRIVATE KEY-----  
MIIEpAIBAAKCAQEAsMGypi...  
-----END RSA PRIVATE KEY-----

出于某种原因,自签名证书在ubuntu上对我不起作用,但在mac os上工作正常。