0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

自己署名証明書を使用した環境でのcurlオプション

Last updated at Posted at 2025-12-07

発端

オレオレ証明書を使用した開発環境で、curlリクエストする処理をPHPで実装していた時のこと、

SSL certificate problem: self signed certificate

エラーが発生。

調査

エラーの内容から最初はプログラムまたは環境に問題があるのだろうと、その辺りを調査・確認したのですが、解決せず…

結論

curlのオプションで、

  • 【証明書の検証】を行わない
CURLOPT_SSL_VERIFYPEER => 0
  • 【ホスト名の検証】を行わない
CURLOPT_SSL_VERIFYHOST => 0

を追加することで問題なく通信できるようになりました。

注意点

このオプションは、あくまでも開発等の閉じた環境でのみ有効となるようにする必要があります。
本番環境では設定されないよう条件判定をお忘れなく。

まとめ

インフラ系がとても苦手で、勉強不足により原因追及に遠まわりしてしまい、解決に時間がかかってしまいました…
知識があればエラーを見て「これは開発環境だから検証しないように設定できないかな?」となったはず。
周辺知識の習得に努めます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?