php - haxe (php) https 调用 : stream_socket_client() Peer certificate CN did not match expected CN

标签 php amazon-web-services https haxe

我正在使用 haxe 的 Http 类(编译为 php)通过 https 将 request() 发送到 AWS。这是一个使用 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;
    }
  }
}

最佳答案

正如此处指出的 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 地址而不是主机名,因此没有解决问题的根源。

关于php - haxe (php) https 调用 : stream_socket_client() Peer certificate CN did not match expected CN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33043617/

相关文章:

php - echo MySql 列名和值

php - fatal error : Uncaught Error: Call to undefined function mysql_pconnect()

php - 在 PHP 中从 SQL 查询结果构建 JSON 对象

java - 如何像在 Google Oauth Playground 中一样向 Google API 发送 HTTP 请求?

php - 替换隐藏在文本中的字符

java - Dynamo DB 中的自动递增计数器

amazon-web-services - 如何使Snowflake作为应用程序后端数据库以实现快速搜索

php - 使用 v4 创建上传表单文件到 s3

facebook - FQL photo 和 photo_src 表 src 使用 http 但不使用 https

node.js - 如果我在 Heroku 或其他托管平台上托管我的 nodejs 应用程序,我可以忽略使用 HTTPS 服务我的应用程序吗?