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

crypto/tls: Intermittent errors with OpenSSL client #3796

Closed
edsrzf opened this issue Jul 3, 2012 · 5 comments
Closed

crypto/tls: Intermittent errors with OpenSSL client #3796

edsrzf opened this issue Jul 3, 2012 · 5 comments

Comments

@edsrzf
Copy link

@edsrzf edsrzf commented Jul 3, 2012

I'm running an HTTPS server and occasionally get client-side errors when trying to send
it a request from a client using OpenSSL.

The error I get from Ruby is:
/usr/lib/ruby/1.9.1/net/http.rb:678:in `connect': SSL_connect returned=1 errno=0
state=SSLv3 read server key exchange B: bad signature (OpenSSL::SSL::SSLError)
    from /usr/lib/ruby/1.9.1/net/http.rb:678:in `block in connect'
    from /usr/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
    from /usr/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
    from /usr/lib/ruby/1.9.1/net/http.rb:678:in `connect'
    from /usr/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
    from /usr/lib/ruby/1.9.1/net/http.rb:626:in `start'
    from /usr/lib/ruby/1.9.1/net/http.rb:1168:in `request'
    from /usr/lib/ruby/1.9.1/net/http.rb:1081:in `request_get'
    from testssl.rb:8:in `block in <main>'
    from testssl.rb:6:in `times'
    from testssl.rb:6:in `<main>'

I've attached a basic HTTPS server and a short Ruby script that can reproduce this
issue. The client makes 1000 requests against the server and this has always been enough
to trigger the problem for me.

Attachments:

  1. server.go (185 bytes)
  2. testssl.rb (189 bytes)
@patrickmn

This comment has been minimized.

Copy link

@patrickmn patrickmn commented Jul 3, 2012

Comment 1:

Reproduced with s_client:
#!/bin/bash
for i in {1..1000}
do
   echo $i | openssl s_client -connect localhost:8080 -quiet
done
"139758768248480:error:04091077:rsa routines:INT_RSA_VERIFY:wrong signature
length:rsa_sign.c:175:
139758768248480:error:1408D07B:SSL routines:SSL3_GET_KEY_EXCHANGE:bad
signature:s3_clnt.c:1796:"
Normal:
140707248211616:error:140943E8:SSL
routines:SSL3_READ_BYTES:reason(1000):s3_pkt.c:1247:SSL alert number 0
depth=0 O = Sniffy, CN = web.sniffy.local
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 O = Sniffy, CN = web.sniffy.local
verify error:num=21:unable to verify the first certificate
verify return:1
^Cdepth=0 O = Sniffy, CN = web.sniffy.local
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 O = Sniffy, CN = web.sniffy.local
verify error:num=21:unable to verify the first certificate
verify return:1
HTTP/1.1 400 Bad Request
Intermittent:
140093522732704:error:140943E8:SSL
routines:SSL3_READ_BYTES:reason(1000):s3_pkt.c:1247:SSL alert number 0
depth=0 O = Sniffy, CN = web.sniffy.local
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 O = Sniffy, CN = web.sniffy.local
verify error:num=21:unable to verify the first certificate
verify return:1
139758768248480:error:04091077:rsa routines:INT_RSA_VERIFY:wrong signature
length:rsa_sign.c:175:
139758768248480:error:1408D07B:SSL routines:SSL3_GET_KEY_EXCHANGE:bad
signature:s3_clnt.c:1796:
depth=0 O = Sniffy, CN = web.sniffy.local
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 O = Sniffy, CN = web.sniffy.local
verify error:num=21:unable to verify the first certificate
verify return:1
HTTP/1.1 400 Bad Request
@patrickmn

This comment has been minimized.

Copy link

@patrickmn patrickmn commented Jul 3, 2012

Comment 2:

^ OpenSSL 1.0.1 14 Mar 2012, x86_64
Go 6e5762cf9a29+ tip (from today)
@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Jul 10, 2012

Comment 3:

Owner changed to @agl.

Status changed to Accepted.

@agl

This comment has been minimized.

Copy link
Contributor

@agl agl commented Jul 10, 2012

Comment 4:

http://golang.org/cl/6352093/ out for review.
@agl

This comment has been minimized.

Copy link
Contributor

@agl agl commented Jul 11, 2012

Comment 5:

This issue was closed by revision 93ea79e.

Status changed to Fixed.

@edsrzf edsrzf added fixed labels Jul 11, 2012
agl added a commit that referenced this issue May 11, 2015
««« backport 46ca86e70e96
crypto/rsa: left-pad PKCS#1 v1.5 outputs.

OpenSSL requires that RSA signatures be exactly the same byte-length
as the modulus. Currently it'll reject ~1/256 of our signatures: those
that end up a byte shorter.

Fixes #3796.

R=golang-dev, edsrzf, r
CC=golang-dev
https://golang.org/cl/6352093

»»»
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.