Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to 2.5.3 results in SSL errors #230

Closed
lucaspiller opened this issue Nov 11, 2014 · 17 comments
Closed

Upgrading to 2.5.3 results in SSL errors #230

lucaspiller opened this issue Nov 11, 2014 · 17 comments
Labels

Comments

@lucaspiller
Copy link

I've just upgraded to 2.5.3.2 and now get an error whenever trying to make a SSL connection with a client certificate:

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpi-2.2.7/lib/httpi/adapter/httpclient.rb:28:in `rescue in request'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpi-2.2.7/lib/httpi/adapter/httpclient.rb:25:in `request'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpi-2.2.7/lib/httpi.rb:159:in `request'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httpi-2.2.7/lib/httpi.rb:131:in `post'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-2.7.2/lib/savon/operation.rb:86:in `block in call_with_logging'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-2.7.2/lib/savon/request_logger.rb:12:in `call'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-2.7.2/lib/savon/request_logger.rb:12:in `log'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-2.7.2/lib/savon/operation.rb:86:in `call_with_logging'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-2.7.2/lib/savon/operation.rb:51:in `call'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-2.7.2/lib/savon/client.rb:36:in `call'
*snip*
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.7/lib/rails/commands/runner.rb:60:in `load'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.7/lib/rails/commands/runner.rb:60:in `<top (required)>'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.7/lib/rails/commands/commands_tasks.rb:128:in `require'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.7/lib/rails/commands/commands_tasks.rb:128:in `require_command!'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.7/lib/rails/commands/commands_tasks.rb:95:in `runner'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.7/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
/Users/luca/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.7/lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:8:in `require'
bin/rails:8:in `<main>'
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

I've tested the certificates directly with OpenSSL and it works fine, as does downgrading to 2.5.2.

@nahi
Copy link
Owner

nahi commented Nov 12, 2014

You mean 2.5.2 works but 2.5.3.2 causes SSLError, right? Interesting... I updated CA certificates in 2.5.3. Mozilla seems to delete some CA certificates in it.

Can you tell me the SSL server endpoint that gives an SSLError? Possibly an intermediate certificate configuration problem.

@nahi nahi added the Feedback label Nov 12, 2014
@lucaspiller
Copy link
Author

Yes that's correct. These are a private third-party services, so I can't provide too many details I'm afraid.

Here is the certificate chain output from running:

openssl s_client -cert cert.pem -key key.pem -connect hostname:port

Note that it only occurred on services where we have to provide client certificates; other services that use regular SSL worked fine - I'm not sure if that's just a coincidence though.

Service 1:

Certificate chain
 0 *snip*
   i:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)10/CN=VeriSign Class 3 Secure Server CA - G3
 1 s:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)10/CN=VeriSign Class 3 Secure Server CA - G3
   i:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5
 2 s:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5
   i:/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority

Service 2:

Certificate chain
 0 *snip*
   i:/C=US/O=Thawte, Inc./CN=Thawte SGC CA - G2
 1 s:/C=US/O=Thawte, Inc./CN=Thawte SGC CA - G2
   i:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5
 2 s:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5
   i:/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority

@nahi
Copy link
Owner

nahi commented Nov 13, 2014

@lucaspiller I see. Can you provide the certificate for this?

 2 s:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5
   i:/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority

Running HTTPClient/2.5.2 with ruby -d should dump all certificates in PEM format like this.

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 903804111 (0x35def4cf)
        Signature Algorithm: sha1WithRSAEncryption
        Issuer: C=US, O=Equifax, OU=Equifax Secure Certificate Authority
        Validity
            Not Before: Aug 22 16:41:51 1998 GMT
            Not After : Aug 22 16:41:51 2018 GMT
        Subject: C=US, O=Equifax, OU=Equifax Secure Certificate Authority
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
            RSA Public Key: (1024 bit)
                Modulus (1024 bit):
                    00:c1:5d:b1:58:67:08:62:ee:a0:9a:2d:1f:08:6d:
                    91:14:68:98:0a:1e:fe:da:04:6f:13:84:62:21:c3:
                    d1:7c:ce:9f:05:e0:b8:01:f0:4e:34:ec:e2:8a:95:
                    04:64:ac:f1:6b:53:5f:05:b3:cb:67:80:bf:42:02:
                    8e:fe:dd:01:09:ec:e1:00:14:4f:fc:fb:f0:0c:dd:
                    43:ba:5b:2b:e1:1f:80:70:99:15:57:93:16:f1:0f:
                    97:6a:b7:c2:68:23:1c:cc:4d:59:30:ac:51:1e:3b:
                    af:2b:d6:ee:63:45:7b:c5:d9:5f:50:d2:e3:50:0f:
                    3a:88:e7:bf:14:fd:e0:c7:b9
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 CRL Distribution Points:
                DirName:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority/CN=CRL1

            X509v3 Private Key Usage Period:
                Not After: Aug 22 16:41:51 2018 GMT
            X509v3 Key Usage:
                Certificate Sign, CRL Sign
            X509v3 Authority Key Identifier:
                keyid:48:E6:68:F9:2B:D2:B2:95:D7:47:D8:23:20:10:4F:33:98:90:9F:D4

            X509v3 Subject Key Identifier:
                48:E6:68:F9:2B:D2:B2:95:D7:47:D8:23:20:10:4F:33:98:90:9F:D4
            X509v3 Basic Constraints:
                CA:TRUE
            1.2.840.113533.7.65.0:
                0...V3.0c....
    Signature Algorithm: sha1WithRSAEncryption
        58:ce:29:ea:fc:f7:de:b5:ce:02:b9:17:b5:85:d1:b9:e3:e0:
        95:cc:25:31:0d:00:a6:92:6e:7f:b6:92:63:9e:50:95:d1:9a:
        6f:e4:11:de:63:85:6e:98:ee:a8:ff:5a:c8:d3:55:b2:66:71:
        57:de:c0:21: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f8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA
A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y
7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh
1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4
-----END CERTIFICATE-----

@nahi
Copy link
Owner

nahi commented Nov 13, 2014

"VeriSign Class 3 Public Primary Certification Authority - G5" issues self signing certificate and Mozilla's CA list that httpclient is using include it. I suspect that the "Class 3 Public Primary Certification Authority" that your server is using has been removed from the CA list.

@yorickpeterse
Copy link
Contributor

I've been experiencing similar problems when requesting files from Amazon S3 using HTTPClient. This can be reproduced as following:

HTTPClient.get('https://s3-eu-west-1.amazonaws.com/rubinius.olery.com/index.txt')

This will result in:

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
from /home/yorickpeterse/.gem/ruby/2.1.4/gems/httpclient-2.5.3.2/lib/httpclient/session.rb:310:in `connect'

This problem does not occur when using HTTPClient 2.5.2.

@knu
Copy link
Contributor

knu commented Nov 14, 2014

The same goes for requesting files from Amazon CloudFront: HTTPClient.get('https://d1c8v1qci5en44.cloudfront.net/da1dc969df_640x640.jpg') leads to OpenSSL::SSL::SSLError.

@nahi
Copy link
Owner

nahi commented Nov 14, 2014

Oops. Huge issue. I'm checking...

@nahi
Copy link
Owner

nahi commented Nov 14, 2014

Too bad both the S3 and CF examples work for me.

% ruby -rhttpclient -e "p HTTPClient.get('https://s3-eu-west-1.amazonaws.com/rubinius.olery.com/index.txt').status"
200
% ruby -rhttpclient -e "p HTTPClient.get('https://d1c8v1qci5en44.cloudfront.net/da1dc969df_640x640.jpg').status"
403
% ruby -rhttpclient -e "p HTTPClient::VERSION"
"2.5.3.2"

@yorickpeterse and @knu , can you provide the result of running the same code with ruby -d? It should dump SSL negotiation status to STDERR.

@nahi
Copy link
Owner

nahi commented Nov 14, 2014

In case of the edge server configuration issue:

% dig s3-eu-west-1.amazonaws.com +noall +answer

; <<>> DiG 9.8.3-P1 <<>> s3-eu-west-1.amazonaws.com +noall +answer
;; global options: +cmd
s3-eu-west-1.amazonaws.com. 50  IN  A   54.231.128.193
% dig d1c8v1qci5en44.cloudfront.net +noall +answer

; <<>> DiG 9.8.3-P1 <<>> d1c8v1qci5en44.cloudfront.net +noall +answer
;; global options: +cmd
d1c8v1qci5en44.cloudfront.net. 60 IN    A   54.239.132.86
d1c8v1qci5en44.cloudfront.net. 60 IN    A   54.230.119.86
d1c8v1qci5en44.cloudfront.net. 60 IN    A   54.230.118.143
d1c8v1qci5en44.cloudfront.net. 60 IN    A   54.230.117.45
d1c8v1qci5en44.cloudfront.net. 60 IN    A   54.230.119.40
d1c8v1qci5en44.cloudfront.net. 60 IN    A   54.192.118.235
d1c8v1qci5en44.cloudfront.net. 60 IN    A   54.239.132.26
d1c8v1qci5en44.cloudfront.net. 60 IN    A   54.239.132.103

@nahi
Copy link
Owner

nahi commented Nov 14, 2014

Mine for S3:

% ruby -d -rhttpclient -e "p HTTPClient.get('https://s3-eu-west-1.amazonaws.com/rubinius.olery.com/index.txt').status"
Exception `LoadError' at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems.rb:1087 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems.rb:1096 - cannot load such file -- rubygems/defaults/ruby
Exception `LoadError' at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55 - cannot load such file -- httpclient
Exception `LoadError' at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55 - cannot load such file -- addressable/uri
Exception `LoadError' at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55 - cannot load such file -- idn
Exception `LoadError' at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:141 - cannot load such file -- idn
Exception `LoadError' at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:141 - cannot load such file -- idn
/Users/nahi/.gem/ruby/2.0.0/gems/httpclient-2.5.3.2/lib/httpclient/cookie.rb:406: warning: private attribute?
ng: "/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5" at depth 2 - 20: unable to get local issuer certificate in [#<OpenSSL::X509::Certificate: subject=#<OpenSSL::X509::Name:0x007f94713e5028>, issuer=#<OpenSSL::X509::Name:0x007f94713e5000>, serial=#<OpenSSL::BN:0x007f94713e4fd8>, not_before=2014-10-02 00:00:00 UTC, not_after=2015-09-05 23:59:59 UTC>, #<OpenSSL::X509::Certificate: subject=#<OpenSSL::X509::Name:0x007f94713e4c68>, issuer=#<OpenSSL::X509::Name:0x007f94713e4c40>, serial=#<OpenSSL::BN:0x007f94713e4c18>, not_before=2010-02-08 00:00:00 UTC, not_after=2020-02-07 23:59:59 UTC>, #<OpenSSL::X509::Certificate: subject=#<OpenSSL::X509::Name:0x007f94713e4858>, issuer=#<OpenSSL::X509::Name:0x007f94713e4830>, serial=#<OpenSSL::BN:0x007f94713e4808>, not_before=2006-11-08 00:00:00 UTC, not_after=2021-11-07 23:59:59 UTC>]
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            35:97:31:87:f3:87:3a:07:32:7e:ce:58:0c:9b:7e:da
        Signature Algorithm: sha1WithRSAEncryption
        Issuer: C=US, O=VeriSign, Inc., OU=Class 3 Public Primary Certification Authority
        Validity
            Not Before: Nov  8 00:00:00 2006 GMT
            Not After : Nov  7 23:59:59 2021 GMT
        Subject: C=US, O=VeriSign, Inc., OU=VeriSign Trust Network, OU=(c) 2006 VeriSign, Inc. - For authorized use only, CN=VeriSign Class 3 Public Primary Certification Authority - G5
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
            RSA Public Key: (2048 bit)
                Modulus (2048 bit):
                    00:af:24:08:08:29:7a:35:9e:60:0c:aa:e7:4b:3b:
                    4e:dc:7c:bc:3c:45:1c:bb:2b:e0:fe:29:02:f9:57:
                    08:a3:64:85:15:27:f5:f1:ad:c8:31:89:5d:22:e8:
                    2a:aa:a6:42:b3:8f:f8:b9:55:b7:b1:b7:4b:b3:fe:
                    8f:7e:07:57:ec:ef:43:db:66:62:15:61:cf:60:0d:
                    a4:d8:de:f8:e0:c3:62:08:3d:54:13:eb:49:ca:59:
                    54:85:26:e5:2b:8f:1b:9f:eb:f5:a1:91:c2:33:49:
                    d8:43:63:6a:52:4b:d2:8f:e8:70:51:4d:d1:89:69:
                    7b:c7:70:f6:b3:dc:12:74:db:7b:5d:4b:56:d3:96:
                    bf:15:77:a1:b0:f4:a2:25:f2:af:1c:92:67:18:e5:
                    f4:06:04:ef:90:b9:e4:00:e4:dd:3a:b5:19:ff:02:
                    ba:f4:3c:ee:e0:8b:eb:37:8b:ec:f4:d7:ac:f2:f6:
                    f0:3d:af:dd:75:91:33:19:1d:1c:40:cb:74:24:19:
                    21:93:d9:14:fe:ac:2a:52:c7:8f:d5:04:49:e4:8d:
                    63:47:88:3c:69:83:cb:fe:47:bd:2b:7e:4f:c5:95:
                    ae:0e:9d:d4:d1:43:c0:67:73:e3:14:08:7e:e5:3f:
                    9f:73:b8:33:0a:cf:5d:3f:34:87:96:8a:ee:53:e8:
                    25:15
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Basic Constraints: critical
                CA:TRUE
            X509v3 CRL Distribution Points:
                URI:http://crl.verisign.com/pca3.crl

            X509v3 Key Usage: critical
                Certificate Sign, CRL Sign
            X509v3 Certificate Policies:
                Policy: X509v3 Any Policy
                  CPS: https://www.verisign.com/cps

            X509v3 Subject Key Identifier:
                7F:D3:65:A7:C2:DD:EC:BB:F0:30:09:F3:43:39:FA:02:AF:33:31:33
            X509v3 Extended Key Usage:
                Netscape Server Gated Crypto, 2.16.840.1.113733.1.8.1, TLS Web Server Authentication, TLS Web Client Authentication
            1.3.6.1.5.5.7.1.12:
                0_.].[0Y0W0U..image/gif0!0.0...+..............k...j.H.,{..0%.#http://logo.verisign.com/vslogo.gif
            Authority Information Access:
                OCSP - URI:http://ocsp.verisign.com

    Signature Algorithm: sha1WithRSAEncryption
        0f:25:ae:48:ed:1b:33:85:4c:0c:b5:c2:d7:fe:4d:d6:83:28:
        4c:41:65:60:00:0b:77:48:71:82:fe:7f:db:5a:0e:20:cc:d2:
        ea:47:bc:64:42:61:44:34:74:30:81:81:26:8a:4a:f7:44:5d:
        7e:34:80:a8:b8:83:e2:09:d7:6d:23:dd:89:ed:28:08:bd:63:
        5a:11:57:08:c4:9e:da:e2:68:28:af:dd:50:3c:ec:82:21:d8:
        00:c2:55:44:50:70:41:ad:83:17:79:ba:08:f3:2b:de:ed:34:
        1d:44:9e:d2:04:93:f4:cb:05:17:2d:09:2d:2d:63:ef:f6:26:
        0b:7b
-----BEGIN CERTIFICATE-----
MIIExjCCBC+gAwIBAgIQNZcxh/OHOgcyfs5YDJt+2jANBgkqhkiG9w0BAQUFADBf
MQswCQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNzA1BgNVBAsT
LkNsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkw
HhcNMDYxMTA4MDAwMDAwWhcNMjExMTA3MjM1OTU5WjCByjELMAkGA1UEBhMCVVMx
FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
dCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAw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CCsGAQUFBzABhhho
dHRwOi8vb2NzcC52ZXJpc2lnbi5jb20wDQYJKoZIhvcNAQEFBQADgYEADyWuSO0b
M4VMDLXC1/5N1oMoTEFlYAALd0hxgv5/21oOIMzS6ke8ZEJhRDR0MIGBJopK90Rd
fjSAqLiD4gnXbSPdie0oCL1jWhFXCMSe2uJoKK/dUDzsgiHYAMJVRFBwQa2DF3m6
CPMr3u00HUSe0gST9MsFFy0JLS1j7/YmC3s=
-----END CERTIFICATE-----
at depth 2 - 20: unable to get local issuer certificate
Protocol version: TLSv1
Cipher: ["AES128-SHA", "TLSv1/SSLv3", 128, 128]
State: SSLOK : SSL negotiation finished successfully
200

@nahi
Copy link
Owner

nahi commented Nov 14, 2014

Hmm, funny the callback is not called for regular path...

@nahi
Copy link
Owner

nahi commented Nov 14, 2014

I confirmed that with OpenSSL 1.0.1 it fails. Investigating...

@nahi
Copy link
Owner

nahi commented Nov 14, 2014

The root cause of this problem is the latest Mozilla CA certs does not have "C=US, O=VeriSign, Inc., OU=Class 3 Public Primary Certification Authority". Firefox is using NSS so there should be another path they can trust these server certificates. For interim fix I released 2.5.3.3 with the previous CA certs.

I'll investigate later and consider what certs we should use for OpenSSL >1.0

@nahi nahi added BUG and removed Feedback labels Nov 14, 2014
@nahi
Copy link
Owner

nahi commented Nov 14, 2014

@lucaspiller @yorickpeterse @knu Would you please try 2.5.3.3 against each server? Thanks for your cooperation!

@yorickpeterse
Copy link
Contributor

Just tested this on 2.5.3.3 and the problem has indeed been resolved for me. Thanks!

@nahi
Copy link
Owner

nahi commented Nov 16, 2014

I found this: http://curl.haxx.se/docs/caextract.html

RSA-1024 removed

Around early September 2014, Mozilla removed the trust bits from the certs in their CA bundle that were still using RSA 1024 bit keys. This may lead to TLS libraries having a hard time to verify some sites if the library in question doesn't properly support "path discovery" as per RFC 4158. (That includes OpenSSL and GnuTLS.)

The last CA bundle we converted from before that cleanup: an older ca-bundle from github.

And HTTPClient/2.5.3.3's CA certs are exactly the same as "before that cleanup" version.

As long as I use OpenSSL I need to find or maintain another list.

@nahi nahi added SSL and removed BUG labels Dec 28, 2014
jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Jan 21, 2015
(with post 2.6.0 fix: bin/httpclient one-liner broken)

## Changes

### Changes in 2.6.0

This release includes internal CookieManager implementation change. It
involves compatibility layer but for the case your library depends on internal
implementation it also provides a way to restore the implementation. See below
for more details.

 * Changes

   * feat: use http-cookie if available for better Cookies spec compliance.

     Instead of WebAgent 0.6.2 that is not maintained over 10 years. To omit
     maintaining that library use http-cookie for better spec compliance and
     healthy development.

     This introduces following incompatibility from existing cookies
     implementation.

     * Expired cookies are not saved. With the old implementation expired
       cookies are saved in file and not be sent to the server. With the new
       implementation the expired cookies are not saved to the file and not
       be sent to the server.
     * Cookie#domain returns dot-less domain for domain cookies. Instead,
       Cookie#dot_domain returns with dot.

     http-cookie is used by default if available but you can restore original
     CookieManager behavior by loading 'httpclient/webagent-cookie' feature
     before 'httpclient' like this;

     ```ruby
     require 'httpclient/webagent-cookie'
     require 'httpclient'
     ```

     The new implementation dumps warnings to help you migrate to http-cookie.
     Please follow the suggestion to avoid future compatibility.

     ```ruby
     e.g.
      WebAgent::Cookie is deprecated and will be replaced with HTTP::Cookie in the near future. Please use Cookie#origin= instead of Cookie#url= for the replacement.
      Cookie#domain returns dot-less domain name now. Use Cookie#dot_domain if you need "." at the beginning.
      CookieManager#find is deprecated and will be removed in near future. Use HTTP::Cookie.cookie_value(CookieManager#cookies) instead
     ```

   * feat: Message#previous to get responses in negotiation

     HTTP::Message#previous keeps previous response in negotiation.  For
     redirection, authorization negotiation and retry from custom filter.
     Closes #234.

   * feat: Add JSONClient

     JSONClient auto-converts Hash <-> JSON in request and response.
     * For POST or PUT request, convert Hash body to JSON String with
       'application/json; charset=utf-8' header.
     * For response, convert JSON String to Hash when content-type is
       '(application|text)/(x-)?json'

     This commit include bin/jsonclient that works as same as bin/httpclient
     not with HTTPClient but with JSONClient.

   * feat: Add download command

     ```
     % httpclient download http://host/path > file
     ```

 * Bug fixes

   * fix: duplicated query params by follow_redirect

     When the original request has query and the server returns redirection
     response with Location, HTTPClient wrongly adds query to the new URI. In
     such case the Location header could include query part;

     ```
     e.g.
      http://originalhost/api/call?limit=10
      -> Location: http://otherhost/api/call?limit=10
     ```

     HTTPClient should just hit the new location '/api/call?limit=10' not
     '/api/call?limit=10&limit=10'. Closes #236.

   * fix: NTLM & Basic dual auth

     When a server returns two or more WWW-Authenticate headers and the first
     one is NTLM, say WWW-Authenticate: NTLM and WWW-Authenticate: Basic in
     this order, HTTPClient sent Basic Authorization header after finishing
     NTLM auth negotiation.

     NTLM auth is a connection authentication scheme so HTTPClient deleted
     the internal auth negotiation state so that NTLM authenticator does not
     do anything after the negotiation has completed. In such case, for the
     subsequent requests, NTLM authenticator does nothing but Basic
     authenticator sends Basic Authorization header to the server that is
     already negotiated via NTLM authenticator. This can cause authentication
     failure.

     This commit changes the internal state handling not to delete the state
     but introduce :done state. NTLM authenticator returns :skip for the
     request to the server that auth negotiation has completed. WWWAuth skips
     other authenticator to avoid above issue.  Closes #157.

   * fix: transplant IO positions to new request in negotiation

     In authorization negotiation HTTP::Message for request is generated for
     each request, of course, but HTTPClient did not care the IO position
     recorded in the previous requests in the subsequent requests.  Closes #130.

   * fix: avoid inconsistent Content-Length and actual body

     If lengths of all posted arguments are known HTTPClient sends
     'Content-Length' as a sum length of all arguments. But the length of
     actual body was wrong because it read as much as possible regardless of
     what IO#size returned. So if the file is getting bigger while HTTPClient
     is processing a request the request has inconsistent Content-Length and
     body.

     This bug is found, and the fix is proposed both by @Teshootub7. Thank
     you very much for patient trouble shooting!  Fixes #117.

   * fix: KeepAliveDisconnected race condition

     As details explained in #84, current HTTPClient's KeepAliveDisconnected
     handling has a race condition bug that allows a client to have
     invalidated connection two or more times. This could be a cause of #185.

     To avoid this, make HTTPClient acquire new connection for retry of
     KeepAliveDisconnected.  Closes #84. Closes #185.

### Changes in 2.5.3

This release includes behavior changes of POST and PUT requests that has
nil as a body. See changes below. Emtpty String as a body is not affected.

 * Changes

   * Update cacert. "Certificate data from Mozilla as of: Tue Oct 28 22:03:58 2014"
     -> Reverted in 2.5.3.3 because it caused unexpected SSLError. See
     nahi/httpclient#230

   * Allow no content POST and PUT.
     Previously POST or PUT with :body => nil meant that 'POST or PUT with 0
     length entity body'. But sometimes you need to POST or PUT actually no
     content which should not have Content-Type nor Content-Length.
     It could be incompatible change for user who POST/PUT-ed with empty body
     but it should be rare, actually WEBrick cannot handle such 'no content'
     POST and PUT. #128.

   * Add default_header property.
     :default_header is for providing default headers Hash that all HTTP
     requests should have, such as custom 'Authorization' header in API.  You
     can override :default_header with :header Hash parameter in HTTP request
     methods.

   * raise if redirect res does not have Location header. #155.

 * Bug fixes

   * Avoid NPE by a cookie without domain=.
     The root cause is still uncertain though. Closes #123

   * Suppress verify_callback warning.
     Because OpenSSL can try multiple certificate chains and some of it can
     fail, and one of them succeeds. For that case warning is irrelevant.
     Let it warn only in $DEBUG mode. #221.

### Changes in 2.5.2

Oct 29, 2014 - version 2.5.2

  * Changes
    * Add :force_basic_auth config - #166, #179, #181.
	  Generally HTTP client must send Authorization header after it gets 401
	  error from server from security reason. But in some situation (e.g.
	  API client) you might want to send Authorization from the beginning.
	  You can turn on/off force_basic_auth flag for sending Authorization
	  header from the beginning. (Of cource, if a request URI matches with
	  the URI you set in set_auth method)

    Syntax:
    ```ruby
      HTTPClient.new(:force_basic_auth => true)
      # or
      c = HTTPClient.new
      c.force_basic_auth = true
    ```

    * Add :base_url to HTTPClient configuration.
    Passing path to get, post, etc. is recognized as a request to
    :base_url + uri.  If you pass full URL :base_url is ignored.

    ```ruby
      api = HTTPClient.new(:base_url => 'https://api.example.com/v1')
      api.get("/users.json") # => Get https://api.example.com/v1/users.json
      api.get("https://localhost/path") # => https://localhost/path
    ```


### Changes in 2.5.1

Oct 19, 2014 - version 2.5.1

  * Changes
	* Allow to specify :query in POST, PUT, DELETE and OPTIONS requests.
      Closes #83.
    * Allow to specify :body in OPTIONS request. Closes #136.


### Changes in 2.5.0

Oct 17, 2014 - version 2.5.0

**IMPORTANT CHANGES**

This version changes (again) default SSL options to help
BEAST/CRIME/POODLE Attack prevension.

 * Disabled SSLv3 in favor of POODLE Attack prevention.
 * Enabled 1/n-1 fragment in favor of BEAST Attack prevention.
 * No TLS compression in favor of CRIME Attack prevention.

You can restore the previous SSL configuration like this;

```ruby
client = HTTPClient.new
client.ssl_config.ssl_version = :SSLv23
client.ssl_config.options = OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_SSLv2
```

  * Changes
	* Change default SSL options. See above.
    * Keep cause error of KeepAliveDisconnected. It allows caller to
	  investigate the cause of KeepAliveDisconnected.


### Changes in 2.4.0

Jun 8, 2014 - version 2.4.0

**IMPORTANT CHANGES**

This version changes default SSL version to :auto (same as nil) to use SSL/TLS
version negotiation.  Former versions use SSLv3 as default that does not connect
via TLS.  This change makes underlying OpenSSL library decide which SSL/TLS
version to use but SSLv2 is disabled.

This change makes your secure connection safer but if you see SSL connection
failure with this version try specifying SSL version to use SSLv3 like;
```
client = HTTPClient.new
client.ssl_config.ssl_version = :SSLv3
```

  * Bug fixes
    * Avoid unnecessary connection retries for OAuth error.
      [#203](nahi/httpclient#203)
	* Make authentication drivers Thread-safe.  Note that HTTPClient instance is
	  Thread-safe for authentication state update but it shares authentication
	  state across threads by design.  If you don't want to share authentication
	  state, such as for using different authentication username/password pair
	  per thread, create HTTPClient instance for each Thread.
      [#200](nahi/httpclient#200)
    * Avoid chunked String recycle in callback block.
      [#193](nahi/httpclient#193)
    * Do not send empty 'oauth_token' in signed request for compatibility.
      [#188](nahi/httpclient#188)
    * Ignore negative Content-Length header from server.
      [#175](nahi/httpclient#175)
    * Fix incorrect use of absolute URL for HTTPS proxy requests.
      [#168](nahi/httpclient#168)
    * Handle UTF characters in chunked bodies.
      [#167](nahi/httpclient#167)
    * A new cookie never be accepted if an HTTPClient has the same expired cookie.
      [#154](nahi/httpclient#154)
	* Allow spaces in NO_PROXY environment like; "hosta, hostb"
      [#141](nahi/httpclient#141)
	* Avoid HttpClient::Message::Body#dump causes Encoding::CompatibilityError.
      [#140](nahi/httpclient#140)

  * Changes
	* Change default SSL version to :auto to use version negotiation.
      [#186](nahi/httpclient#186),
      [#204](nahi/httpclient#204)
    * Allow to pass client private key passphrase in SSLConfig.
      [#201](nahi/httpclient#201)
    * Convert README to markdown syntax
      [#198](nahi/httpclient#198)
    * Update default CA certificates: change the source from JDK's to Firefox's.
      The file is downloaded from
	  https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt
	  (Certificate data from Mozilla as of: Tue Apr 22 08:29:31 2014)
      [#195](nahi/httpclient#195)
	* Callback block can be defined as to get 2 arguments to retrieve the
	  response object.
      [#194](nahi/httpclient#194)
    * Remove [] from given address for IPv6 compat.
      [#176](nahi/httpclient#176)
    * Update API endpoints to those of Twitter REST API v1.1.
      [#150](nahi/httpclient#150)
nahi pushed a commit that referenced this issue Nov 3, 2015
Issue #230 blocked updating trusted CA certificates to 2048 bit version
long time. But from OpenSSL 1.0.1m and 1.0.2a it changes their custom
chain building algorithm to find shortcut path when it fails to validate
the path SSL server returns so that we can migrate trusted CA
certificates to 2048bit version atop OpenSSL.

Unfortunately the new algorithm has CVE-2015-1793 problem so we can use
this new algorithm actually from OpenSSL >= 1.0.1p or >= 1.0.2d. (Jul
2015)

After this commit HTTPClient leverages 2048 bit version of trusted CA
certificates if ruby is compiled with proper version of OpenSSL.

```
ver = OpenSSL::OPENSSL_VERSION
if (ver.start_with?('OpenSSL 1.0.1') && ver >= 'OpenSSL 1.0.1p') ||
    (ver.start_with?('OpenSSL ') && ver >= 'OpenSSL 1.0.2d')
  filename = 'cacert.pem'
else
  filename = 'cacert1024.pem'
end
```
@nahi
Copy link
Owner

nahi commented Nov 3, 2015

e70ec73 solved this issue.

@nahi nahi closed this as completed Nov 3, 2015
zunda added a commit to zunda/rubykaigi2015-lt that referenced this issue Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants