-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Server loads incorrect certificate from Windows Certificate Store #6024
Comments
Input value should be hex-encoded string of the SHA1 thumbprint. See: #6024 Signed-off-by: Neil Twigg <neil@nats.io>
Have prepared a branch that should let you specify the certificate by the SHA1 thumbprint instead:
Can you please give it a try? |
This PR: * Removes some magic numbers from the certstore code in favour of constants already defined in `x/sys/windows` * Adds the `thumbprint` option to `cert_match_by` by allowing matching a specific certificate my SHA1 thumbprint rather than possibly matching multiple certificates by name * Adds the `cert_match_skip_invalid` option by integrating & rebasing a community PR along with some fix-ups Fixes #6024 Fixes #4383 Closes #4384 Signed-off-by: Neil Twigg <neil@nats.io>
Hi @neilalexander, many thanks for having a look at this issue!
|
I wonder if |
Hmm, you could be right, can you try this instead? |
No luck I'm afraid, same error message |
Ah, I see the problem. Please give this one a go — I've tested it on a Windows virtual machine: |
Amazing! That one is working great |
Thanks for confirming, have raised PR #6047. |
Input value should be hex-encoded string of the SHA1 thumbprint. See: #6024 Signed-off-by: Neil Twigg <neil@nats.io>
Input value should be hex-encoded string of the SHA1 thumbprint. See: #6024 Signed-off-by: Neil Twigg <neil@nats.io>
Observed behavior
I start
nats-server.exe
with the following configuration:My Windows Certificate Store has multiple test certificates defined, with similar subject names. One is called
MyCertificate
, anotherMyCertificateForClient
. The former is fully trusted (as it is also registered as a Trusted Root CA), and is the certificate I expect the server to load.Expected behavior
The server loads certificate
MyCertificateForClient
. I am unable to connect to the server, with the following error:Server and client version
nats-server: v2.10.22
Host environment
Windows 10, AMD64
Steps to reproduce
It looks like this is due to use of
CERT_FIND_ISSUER_STR
orCERT_FIND_SUBJECT_STR
, more details here. The lookup is for a certificate that "contains the specified string", which both of my test certificates satisfy.Furthermore, certificates within the store are unordered, and I also suspect that the server could retrieve expired, revoked or untrusted certificates in favour of one that can actually be used.
I found a comment with similar issue here. The follow up here makes sense to me - if I could specify a certificate by thumbprint I could guarantee that the correct certificate is loaded.
See also
#2130
https://github.com/nats-io/nats-architecture-and-design/blob/main/adr/ADR-39.md
The text was updated successfully, but these errors were encountered: