それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

cygwinのcurl がSSLエラーになる(CA証明書をインストール

curlhttps にアクセスしたらSSLの検証がエラーになった

takuya@letsnote:~$ curl https://github.com/gyazo/Gyazo.git
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

調べてみたら
http://www.goodpic.com/mt/archives2/2011/02/github_clonessl.html:tite
どうやらCurlSSLでエラーになると事が原因らしい。GitもWgetCurlも同じ理由で落ちているらしい。とりあえずCurlのエラーに対応する。

エラーの内容の指定されたURLをたたくと

These days, the curl archives include no ca certs at
all. You need to get them elsewhere. See below for example.

cURL - SSL CA Certificates

最近のcurlはCAのCERTをバンドルしてないのでOS標準で用意されてるモノか、自分で用意しろってことです。
詳しく読むと

PATHが通っているところにcurl-ca-bundle.crtを置けばいいとのこと

4. If you're using the curl command line tool, you can specify your own CA
cert path by setting the environment variable CURL_CA_BUNDLE to the path
of your choice.

If you're using the curl command line tool on Windows, curl will search
for a CA cert file named "curl-ca-bundle.crt" in these directories and in
this order:
1. application's directory
2. current working directory
3. Windows System directory (e.g. C:\windows\system32)
4. Windows Directory (e.g. C:\windows)
5. all directories along %PATH%

cURL - SSL CA Certificates

つまりFirefoxから証明書を取り出せばいいとのこと

bagder/curl · GitHubを使ってFirefoxからルート証明書一式を取り出して使えばいいと分かった。

  1. $HOME/.mozilla/以下から証明書を取り出してcertutilで変換するらしい
  2. LinuxFirefoxが想定されているので適当なLinuxFirefoxを動かしたことがあるもの)
  3. certutilコマンドは libnss3-toolsで手に入るらしい

取り出してみた

Linuxのデスクトップで次を実行

sudo apt-get install libnss3-tools
vim  firefox-db2pem.sh 
sh firefox-db2pem.sh 
ls -l ca-bundle.crt

Cygwinに戻って

scp 192.168.22.5:~/  .
export CURL_CA_BUNDLE=~/ca-bundle.crt
curl https://mixi.jp

エラーが消えた

環境変数を設定したらエラーが消えた

はい。できあがり。Curlは解決した


それでもWgetやGitはエラーになる。