curl で SSL が繋げない  curl: (35) SSL connect error

## BEFORE

`--verbose` すると、TLSのハンドシェイクで失敗して、 SSLv3　でつなぎに行こうとしているのが分かる。

>Error in TLS handshake, trying SSLv3...

```
[root@2f13a8e79be2 /]# curl --verbose https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent2.sh
* About to connect() to toolbelt.treasuredata.com port 443 (#0)
*   Trying 151.101.89.177... connected
* Connected to toolbelt.treasuredata.com (151.101.89.177) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS error -12190
* Error in TLS handshake, trying SSLv3...
> GET /sh/install-ubuntu-xenial-td-agent2.sh HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: toolbelt.treasuredata.com
> Accept: */*
>
* Connection died, retrying a fresh connect
* Closing connection #0
* Issue another request to this URL: 'https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent2.sh'
* About to connect() to toolbelt.treasuredata.com port 443 (#0)
*   Trying 151.101.89.177... connected
* Connected to toolbelt.treasuredata.com (151.101.89.177) port 443 (#0)
* TLS disabled due to previous handshake failure
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS error -12286
* Closing connection #0
* SSL connect error
curl: (35) SSL connect error
```

## nss のアップデート

nss を アップデートしてみる。

```
[root@f44f49e49007 /]# yum info nss

Installed Packages
Name        : nss
Arch        : x86_64
Version     : 3.16.1
Release     : 14.el6
Size        : 2.5 M
Repo        : installed
From repo   : CentOS
Summary     : Network Security Services
URL         : http://www.mozilla.org/projects/security/pki/nss/
License     : MPLv2.0
Description : Network Security Services (NSS) is a set of libraries designed to
            : support cross-platform development of security-enabled client and
            : server applications. Applications built with NSS can support SSL v2
            : and v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509
            : v3 certificates, and other security standards.

Available Packages
Name        : nss
Arch        : i686
Version     : 3.28.4
Release     : 4.el6_9
Size        : 882 k
Repo        : updates
Summary     : Network Security Services
URL         : http://www.mozilla.org/projects/security/pki/nss/
License     : MPLv2.0
Description : Network Security Services (NSS) is a set of libraries designed to
            : support cross-platform development of security-enabled client and
            : server applications. Applications built with NSS can support SSL v2
            : and v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509
            : v3 certificates, and other security standards.
```

```
yum update nss
```

## AFTER

TLSで通信できるようになったみたいだ。

>SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

```
[root@e7495fa27993 /]# curl --verbose --head https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent2.sh
* About to connect() to toolbelt.treasuredata.com port 443 (#0)
*   Trying 151.101.89.177... connected
* Connected to toolbelt.treasuredata.com (151.101.89.177) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* 	subject: CN=l.ssl.fastly.net,O="Fastly, Inc.",L=San Francisco,ST=California,C=US
* 	start date: Apr 13 18:39:09 2018 GMT
* 	expire date: Jun 11 18:15:41 2020 GMT
* 	common name: l.ssl.fastly.net
* 	issuer: CN=GlobalSign Organization Validation CA - SHA256 - G2,O=GlobalSign nv-sa,C=BE
> HEAD /sh/install-ubuntu-xenial-td-agent2.sh HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: toolbelt.treasuredata.com
> Accept: */*
>
...
```

# 環境

- Centos6.6 ( docker )
- Docker version 18.03.1-ce, build 9ee9f40

# 参考

- [WgetやCurlでGitHubのSSLが怒られた時 - Qiita](https://qiita.com/Yangsin/items/86a35f1dc70545b34cc4)
- [SSL/TLS（SSL3.0～TLS1.2）のハンドシェイクを復習する - Qiita](https://qiita.com/n-i-e/items/41673fd16d7bd1189a29)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->