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

Crashes when using AddChainCertificate on go 1.3 and 1.3.2 #10

Closed
sajal opened this issue Sep 28, 2014 · 5 comments
Closed

Crashes when using AddChainCertificate on go 1.3 and 1.3.2 #10

sajal opened this issue Sep 28, 2014 · 5 comments

Comments

@sajal
Copy link

sajal commented Sep 28, 2014

reproducable code: http://paste.ubuntu.com/8450867/

When provided with a valid certificate, bundle and key , the pasted code works fine on Go 1.2.2, but crashes on 1.3 and 1.3.2 .

Crashdump: http://pastie.org/private/eszbzktmuyk5o1fgztc6nw

Each time it manages to get 5 to 10 requests out before crashing.

To reproduce, run the following :

go build reproduce.go && sudo ./reproduce -cert=/path/to/cert.crt -key=/path/to/key.key -bundle=/path/to/bundle.crt
on another window.
openssl s_client -connect 127.0.0.1:443 -CApath /etc/ssl/certs
This command successfully validates the cert now that we have the chain added.. but...
Run this about 5 to 10 times and it should crash the server...

My environment
Ubuntu 14.04 (3.13.0-34-generic)
libssl-dev:amd64 1.0.1f-1ubuntu2.5

@jtolio
Copy link
Member

jtolio commented Oct 8, 2014

Just to clarify, I'm assuming this doesn't crash with a go 1.2 release, correct?

@sajal
Copy link
Author

sajal commented Oct 8, 2014

correct

@lunixbochs
Copy link
Contributor

Here's a version of the test that generates its own CA+cert using my fork for easier testing: https://gist.github.com/lunixbochs/9f31135372b2760618e9

I'm looking into the crash.

@lunixbochs
Copy link
Contributor

I'm pretty sure this happens when Go garbage collects the CA certificate because it's no longer used, and the underlying C object is freed.

runtime.SetFinalizer(c, func(c *Certificate) {
    C.X509_free(c.x)
})

This can probably be solved by keeping a reference to the certificate on the ctx object, which should probably be done every time we ask OpenSSL to reference an underlying C object of a Go class.

@jtolio
Copy link
Member

jtolio commented Nov 13, 2014

nice work @lunixbochs

lunixbochs added a commit to lunixbochs/go-openssl that referenced this issue Nov 13, 2014
lunixbochs added a commit to lunixbochs/go-openssl that referenced this issue Nov 14, 2014
lunixbochs added a commit to lunixbochs/go-openssl that referenced this issue Nov 15, 2014
lunixbochs added a commit to lunixbochs/go-openssl that referenced this issue Nov 15, 2014
lunixbochs added a commit to lunixbochs/go-openssl that referenced this issue Nov 15, 2014
lunixbochs added a commit to lunixbochs/go-openssl that referenced this issue Nov 15, 2014
@jtolio jtolio closed this as completed in 1a2646c Nov 19, 2014
merlin-northern added a commit to merlin-northern/openssl that referenced this issue Aug 20, 2020
…rivate_key_review

EngineLoadPrivateKey wrapper over ENGINE_load_private_key
nathan454 pushed a commit to nathan454/openssl that referenced this issue Nov 30, 2022
…; made PEM file splitter tolerant of trailing whitespace in PEM block delimiter lines
nathan454 pushed a commit to nathan454/openssl that referenced this issue Nov 30, 2022
Enabled PEM files with CRLF line endings to be used (spacemonkeygo#10)
BenMatase pushed a commit to mistsys/openssl that referenced this issue Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants