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

x509: certificate is valid for drand.example.com, not drand.example.com:443 #41

Closed
mahrud opened this issue Jun 29, 2018 · 6 comments
Closed

Comments

@mahrud
Copy link

mahrud commented Jun 29, 2018

In this line, the serverNameOverride parameter is set to be the host:port address, which is different from the server name:
https://github.com/dedis/drand/blob/5aae894956265da27653de203863f4f045915226/net/client_grpc.go#L122
In particular, I got a pretty strange error when testing drand run:
dkg: failed to send deal to drand.example.com:443: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: authentication handshake failed: x509: certificate is valid for *.example.com, drand.example.com, not drand.example.com:443"

I think this could also be a side effect (if not bug) of my load balancer setup, but I realized that the docs for NewClientTLSFromFile suggest that this parameter be used only for testing:

// NewClientTLSFromFile constructs TLS credentials from the input certificate file for client.
// serverNameOverride is for testing only. If set to a non empty string,
// it will override the virtual host name of authority (e.g. :authority header field) in requests.
func NewClientTLSFromFile(certFile, serverNameOverride string) (TransportCredentials, error) {

Is p.Address() needed there? If not, removing it will relieve some headache on my end.

@nikkolasg
Copy link
Collaborator

So when I put the serverNameOverride to "", the tests fail with

authentication handshake failed: x509: cannot validate certificate for 127.0.0.1 because it doesn't contain any IP SANs

Since it's explicitely stated as a testing method, I figure we need to remove that call to NewClientTLSFromFile and separate that "testing logic" from the main logic, while still being reachable from the main command line, because I need to be able to indicate custom certificates on the cli flags to run the docker test.

Basically, that would require separating the method creating new connections into two, and have two ways of a creating a GRPC client: regular one that will not even need TransportCredentials since it will use the OS root trust store, and one that uses this NewClientTLSFromFile.

@nikkolasg
Copy link
Collaborator

I'll try to see what I can come up with this week, but that's gonna take a little bit of time though, so I can't promise anything.

@mahrud
Copy link
Author

mahrud commented Jul 1, 2018

I think only serverNameOverride is for testing, not the method itself.

I can think of a couple of simpler ways that don't require two separate calls. One is to separate the port number as its own parameter for each node, the other is to have an optional parameter that is the SNI.

I'm working on a branch with a few fixes, I can implement this and let me know if it doesn't pass the tests.

@nikkolasg
Copy link
Collaborator

I've come up with a way to disable the serverNameOverride ( = ""): I found out that the third party library I use to generate on the fly certificates did not add correctly the IP SANS when I gave the IP address of a node so it was added as a regular DNS name. I'm working on a PR to fix that, should be done soon.

@nikkolasg
Copy link
Collaborator

nikkolasg commented Jul 1, 2018

Hopefully #44 should have solved the problem, let me know if you have still issues with it otherwise feel free to close it.

@mahrud
Copy link
Author

mahrud commented Jul 2, 2018

It seems to be working, thanks!

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