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

TlsConnector adds certificate chain from PKCS12 identity in reverse order #110

Closed
ancwrd1 opened this issue Oct 21, 2018 · 5 comments
Closed

Comments

@ancwrd1
Copy link

ancwrd1 commented Oct 21, 2018

Using native-tls 0.2.1 on Linux (openssl).

When building TlsConnector with pkcs12 identity which contains 3 certificates: [leaf, intermediate, root] the intermediate and root certificates are sent to the server peer in reverse order [leaf, root, intermediate] resulting in handshake errors (in particular the javax.net.ssl.SSLException: subject/issuer name chaining check failed).

@sfackler
Copy link
Owner

What order are the certificates stored in the PKCS12 file?

@ancwrd1
Copy link
Author

ancwrd1 commented Oct 21, 2018

If I dump it with keytool the order is correct:
Certificate[1]: leaf
Certificate[2]: intermediate
Certificate[3]: root

It also works fine with Java TLS client or for example with openssl s_client command when exported into pem file (openssl pkcs12 -in identity.p12 -out server.pem -nodes) and the pem file has it listed in proper order as well: [private key, leaf, intermediate, root].

sfackler added a commit that referenced this issue Oct 22, 2018
The stack is the reverse of what you might expect due to the way
PKCS12_parse is implemented, so we need to load it backwards.

Closes #110
@sfackler
Copy link
Owner

#111 should fix this - could you try it out to confirm?

@ancwrd1
Copy link
Author

ancwrd1 commented Oct 22, 2018

#111 should fix this - could you try it out to confirm?

I think it's only implemented for TlsAcceptor in this PR, should be also changed for TlsConnector. When I change it manually it works, yes.

@sfackler
Copy link
Owner

Great! I'll cut a release with the fix this morning.

sfackler added a commit that referenced this issue Oct 22, 2018
The stack is the reverse of what you might expect due to the way
PKCS12_parse is implemented, so we need to load it backwards.

Closes #110
@kazk kazk mentioned this issue Nov 8, 2021
3 tasks
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

2 participants