ブログ

Debian Buster:cURLが失敗してしまう場合の対策について

at_takuma.fukuda
2021年7月4日 20時51分

Debian Buster環境とDebian Stretch環境で、 cURL等の挙動が異なることがあります。
例えば、「https://www.atmark-techno.com」に対してcURLを実行した場合、
Debian Stretch環境では特に問題無くhtmlデータを取得しますが、
Debian Buster環境では、下記のようなエラーが発生して正常に処理を完了できません。

[armadillo] curl https://www.atmark-techno.com
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html
 
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

この直接的な原因はcURLのビルドの仕方が違う事にあります。
Debian StretchではcURLにCA証明書がバンドルされるようにビルドされているのに対して、
Debian BusterではcURLにCA証明書がバンドルされないようにビルドされています。

そのためDebian Buster環境ではcURL実行時にユーザランド上の外部CA証明書を使用するのですが、
この証明書が古いために上記のようなエラーが表示されてしまいます。

本件の対処方法は、CA証明書を更新することとなります。

以下のコマンドを実行して更新を行ってください。

[armadillo] update-ca-certificates --fresh

「--fresh」のオプションが無いと更新に失敗する場合があるのでお気を付けください。
こちらを実行した後に再度cURLを実行すると、以下のように無事にhtmlデータが取得できることが確認出来ます。

root@armadillo:~# curl https://www.atmark-techno.com
<!DOCTYPE html>
<html lang="ja" dir="ltr" prefix="content: http://purl.org/rss/1.0/modules/content/  dc: http://purl.org/dc/terms/  foaf: http://xmlns.com/foaf/0.1/  og: http://ogp.me/ns#  rdfs: http://www.w3.org/2000/01/rdf-schema#  schema: http://schema.org/  sioc: http://rdfs.org/sioc/ns#  sioct: http://rdfs.org/sioc/types#  skos: http://www.w3.org/2004/02/skos/core#  xsd: http://www.w3.org/2001/XMLSchema# ">
(中略)
</html>