Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
19
Help us understand the problem. What is going on with this article?
@morita21

[PHP] HTTP_Request2のSSLエラーの対処方法

More than 5 years have passed since last update.

HTTP_Request2でhttp通信はできたけど、
接続先をhttpsにしただけでエラーが出た場合の対処方法のメモ。

Unable to connect to ssl://example.com:443. Error: stream_socket_client(): unable to connect to ssl://example.com:443 (Unknown error)
stream_socket_client(): Failed to enable crypto
stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed 

方法1. ssl_capathを指定する

デフォルトのSocketアダプターを使う場合は、SSL証明書のディレクトリ・パスを指定する。

$request = new HTTP_Request2('https://example.com');
$request->setConfig(array(
    'ssl_capath' => '/etc/ssl/certs', // ubuntuの場合
));

方法2. cURLアダプターを使う

cURLアダプターを使えば何もしなくていい。

$request = new HTTP_Request2('https://example.com');
$request->setAdapter('curl');

PHPのcURLエクステンションが入ってない場合は以下のコマンドでインストール。

sudo apt-get install php5-curl

参考

19
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
19
Help us understand the problem. What is going on with this article?