Distributed Services With Go - Failure with Mutual TLS

Failure with Mutual TLS

Title: Distributed Services with Go (pdf page 85)
Tests fails when server attempts to use mutual TLS (setting the Server property in TLSConfig to true). Previous tests that uses TLS to only authenticate the server passes without any problem. Is there anyway to debug what might be the cause of the problem?

Example of asserted error:

--- FAIL: TestServer/produce/consume_a_message_to/from_the_log_succeeds (0.01s)
        server_test.go:105:
            	Error Trace:	server_test.go:105
            	            				server_test.go:31
            	Error:      	Received unexpected error:
            	            	rpc error: code = Unavailable desc = connection closed
            	Test:       	TestServer/produce/consume_a_message_to/from_the_log_succeeds
3 Likes

For those that face this…

You have to update two things.

Add the client key and cert to the config in config/files.go

var (
	CAFile         = configFile("ca.pem")
	ServerCertFile = configFile("server.pem")
	ServerKeyFile  = configFile("server-key.pem")
	ClientCertFile = configFile("client.pem")               // <---
	ClientKeyFile  = configFile(("client-key.pem"))    // <---
)

Update the client tls configuration to utilize the generated client cert and key files added to the config in server/server_test.go

	clientTLSConfig, err := config.SetupTLSConfig(config.TLSConfig{
		CertFile: config.ClientCertFile,              // <---
		KeyFile:  config.ClientKeyFile,               // <---
		CAFile:   config.CAFile,
		Server:   false,                                          // <---
	})

Thanks, I’m looking at fixing this.

csrfr’s comment is correct. The fix will be in the final version of the book. Thanks!