haxe(php)https call:stream_socket_client()对等证书CN与预期的CN不匹配

时间:2015-10-09 16:58:55

标签: php amazon-web-services https haxe

我正在使用haxe的Http类(编译为php)通过https向https发送request()。这是使用haxe-aws库(https://github.com/Blank101/haxe-aws)的最小示例:

var iamconf = new IAMConfig('newbucket.s3-eu-central-1.amazonaws.com', accessKey, secretKey, 'eu-central-1', 's3');
var sig4 = new Sig4Http('https://newbucket.s3-eu-central-1.amazonaws.com/', iamconf);
sig4.applySigning(true);
sig4.setPostData('<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><LocationConstraint>eu-central-1</LocationConstraint></CreateBucketConfiguration>');
sig4.request(true);

无论我使用哪种服务/端点,响应总是:

stream_socket_client(): Peer certificate CN=`*.s3.eu-central-1.amazonaws.com' did not match expected CN=`54.231.192.50' (errno: 2) in [...]lib\sys\net\Socket.class.php at line #34

请求http工作。有什么想法吗?

修改 代码的负责部分,为什么IP地址用于连接而不是名称:

if(!php_Boot::$skip_constructor) {
  if(_hx_deref(new EReg("^(\\d{1,3}\\.){3}\\d{1,3}\$", ""))->match($name)) {
    $this->_ip = $name;
  } else {
    $this->_ip = gethostbyname($name);
    if($this->_ip === $name) {
      $this->ip = 0;
      return;
    }
  }
}

1 个答案:

答案 0 :(得分:1)

正如此处https://groups.google.com/forum/#!msg/haxelang/JMSBpF2sOi0/QpoNEjk9EQAJ和此处http://php.net/manual/en/migration56.openssl.php所指出的,PHP 5.6中的openssl扩展默认使用对等验证。因此,切换回PHP 5.5是一种解决方法,因为此处禁用了对等验证。但是它仍然使用IP地址而不是主机名,因此无法解决问题的根源。