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 rejected: [SelfSigned]" #291

Open
o1lo01ol1o opened this issue Nov 1, 2018 · 7 comments
Open

"certificate rejected: [SelfSigned]" #291

o1lo01ol1o opened this issue Nov 1, 2018 · 7 comments

Comments

@o1lo01ol1o
Copy link

Hi, I'm running into an issue connecting to a third-party's api using a provided certificate. I've configured the supported ciphers and created a cert store using only the top-level client certificate as per their instructions. (I omit intermediary certificates also per their instructions.)

This results in:

InternalException (HandshakeFailed (Error_Protocol ("certificate rejected: [SelfSigned]",True,CertificateUnknown

Could anyone shed some light onto what it might mean?

@ocheron
Copy link
Contributor

ocheron commented Nov 1, 2018

If this exception is thrown by the client, this means it does not trust the root CA given by the server.

You mention a step about a client certificate, but the server root certificate must also be added to sharedCAStore in clientShared.

@o1lo01ol1o
Copy link
Author

o1lo01ol1o commented Nov 1, 2018

@ocheron Thanks for the info, that's helpful. Is there any ordering required to correctly populate the store?

Is it as simple as makeCertificateStore [clientCert, rootCert]?

I ask because including both the root and the client yields a 500 ... The digital certificate is invalid. As does including all intermediary certificates in the chain. However, the client certificate works when installed in the browser and pointed to the test endpoint.

@ocheron
Copy link
Contributor

ocheron commented Nov 2, 2018

The client certificate does not go to sharedCAStore but sharedCredentials instead.
You need to provide both the client certificate chain and private key.

@o1lo01ol1o
Copy link
Author

In the end I needed to provide the onCertificateRequest ClientHook to pull out the credential I provided in sharedCredentials when the server requested it. Is this the intended usage? It seems more than a little confusing to have already provided sharedCredentials to the TLSSettings and then also be required to write the callback that finds the needed credentials when they're asked for. If it is the intended usage of the library, some documentation would have saved me a significant amount of time learning this.

@ocheron
Copy link
Contributor

ocheron commented Nov 4, 2018

Yes you're right, it is onCertificateRequest and not sharedCredentials, sorry.
Documentation will be very welcome if you can contribute some.

@o1lo01ol1o
Copy link
Author

Where should such documentation live? It would likely only be a minimal code example and text.

@ocheron
Copy link
Contributor

ocheron commented Nov 10, 2018

We can start with simplest possible thing, it's always possible to refactor later when more content is available. I'm thinking EXAMPLES.md at top-level. Or something similar to module Crypto.Tutorial, then in core.

Primary goal is to show what ClientParams to use. Possibly with tls only, or from context of package connection. Improving the Haddock comments on parameters is also something we need.

What works best for you and you feel most useful to avoid the issue you ran into.

kazu-yamamoto pushed a commit to kazu-yamamoto/hs-tls that referenced this issue Nov 12, 2018
sharedCredentials is not necessary, see haskell-tls#291.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants