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

Certificate Chain when using ListenAndServeTLS #4

Closed
sadbox opened this issue May 20, 2014 · 10 comments
Closed

Certificate Chain when using ListenAndServeTLS #4

sadbox opened this issue May 20, 2014 · 10 comments

Comments

@sadbox
Copy link

sadbox commented May 20, 2014

When I use a certificate chain in ListenAndServeTLS it doesn't seem to serve up any more than the first certificate. This works properly using the stdlib's ListenAndServeTLS.

@zowens
Copy link
Contributor

zowens commented May 20, 2014

I got around this by adding AddChainCertificate, which you can use to add subordinate certificates. It may be a good idea to add some sort of function to parse the certificate and detect a chain. However, I don't think there's an analog for that behavior in openssl.

@jtolio
Copy link
Member

jtolio commented May 20, 2014

yep, thanks zowens. we had been adding certificates separately to the certificate store manually (GetCertificateStore), but AddChainCertificate was a good addition.

sadbox: okay to close the ticket or is there something else you'd like us to do?

@sadbox
Copy link
Author

sadbox commented May 20, 2014

I could take a look at making something to detect whether it's a chain or not, just depends on what @jtolds would like. In the mean time I'll just manually add the chain.

@jtolio
Copy link
Member

jtolio commented May 20, 2014

It would be nice to have something nicer for people used to the Go lib behavior. If that's something you'd like to do I'd be happy to pull it in.

@lunixbochs
Copy link
Contributor

I might be willing to do this. What if LoadCertificateFromPEM could return multiple certs, then the caller decides how to chain them? (or a new function, LoadCertificatesFromPEM).

Based on the basic PEM "spec" found here, my proposed solution would be to split the PEM into its sections using a multiline regex like this: (^-----[\s-]*?BEGIN.*?-----$.*?^-----[\s-]*?END.*?-----$), then parse each section as a separate cert.

@jtolio
Copy link
Member

jtolio commented Nov 13, 2014

go's standard library actually already has a PEM parser which seems fine to use (http://golang.org/pkg/encoding/pem/), but that sounds good to me lunixbochs

@lunixbochs
Copy link
Contributor

I do like the idea of using Go's internal one, but the next step feels a little weird. I guess we could use the internal DER format they generate, or re-marshal the individual certs as PEM? I think it's adding an abstraction + place to fail, and I don't know where Block.headers come into play.

@jtolio
Copy link
Member

jtolio commented Nov 13, 2014

yeah i think the DER format isn't internal or go-specific here, it should just be something openssl can understand as-is, though the openssl der operations are super undocumented cause openssl docs suck. we use a few of them in a few places, i think they're the i2d and d2i type operations?

@lunixbochs
Copy link
Contributor

This should be fixed by #21, though someone should test it.

@zeebo
Copy link
Member

zeebo commented Mar 3, 2017

Closing due to inactivity.

@zeebo zeebo closed this as completed Mar 3, 2017
nathan454 pushed a commit to nathan454/openssl that referenced this issue Nov 30, 2022
pass build flags on Solaris/Illumos
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

5 participants