LoginSignup
3

More than 3 years have passed since last update.

WordpressからS3につなごうとして"There was an error attempting to get the region of the bucket"が発生した

Posted at

概要

ローカル環境でWordpressを構築し、そこからS3へつなごうとした際にタイトルのエラーが発生しました。

Error Getting Bucket Region —There was an error attempting to get the region of the bucket <バケット名>: Error executing "GetBucketLocation" on "<バケットのURL>?location"; AWS HTTP error: cURL error 60: (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

原因

内容はCURLでS3へつなぐ際にコード60のエラーが発生しているというものです。コード60は次のようになっています。

CURLE_PEER_FAILED_VERIFICATION (60)
The remote server's SSL certificate or SSH md5 fingerprint was deemed not OK. This error code has been unified with CURLE_SSL_CACERT since 7.62.0. Its previous value was 51. - libcurl error codes

これだけでは少しわかりづらいですが、調べていると次のような記述を発見しました。

OSにバンドルされているルート証明書などが古いので証明書の検証ができない様子。 - curl: (60) SSL certificate problem, verify that the CA cert is OK

私の解釈ですが、つなぎ先サーバのSSL証明書とつなぎ元端末のSSL証明書を検証した際、つなぎ元端末のSSL証明書が存在しないor古いために発生するエラーと考えられます。こちらは次の対策をすることで解決しました。

対処法

まず、次のサイトより最新の証明書(cacert.pem)をダウンロードします。

CA certificates extracted from Mozilla

次に作成したwordpressプロジェクトのconf/phpフォルダ配下にphp.ini.hbsというファイルがありますので、そのファイルの一番下に次のコードを追加します。

php.ini.hbs
[curl]
curl.cainfo = "<ダウンロードしたcacert.pemのパス>"

Wordpressプロジェクトを再起動し、WP Offload Media Liteの設定画面でS3のバケットを選択すると接続ができるようになっているはずです。

参考:
curl: (60) SSL certificate problem: unable to get local issuer certificate
cURL error 60: SSL certificate problem: certificate has expired

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
3