# Distributed Services With Go - Failure with Mutual TLS

**URL:** <https://forum.devtalk.com/t/distributed-services-with-go-failure-with-mutual-tls/861>\
**Category:** PragProg Customers\
**Tags:** book-distributed-services-with-go, help-needed\
**Created:** [18 June 2020 09:35 UTC](https://forum.devtalk.com/t/distributed-services-with-go-failure-with-mutual-tls/861 "2020-06-18T09:35:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tphume](https://forum.devtalk.com/user_avatar/forum.devtalk.com/tphume/32/1079_2.png) [@tphume](https://forum.devtalk.com/u/tphume)\
**Post date:** [18 June 2020 09:35 UTC](https://forum.devtalk.com/t/distributed-services-with-go-failure-with-mutual-tls/861/1 "2020-06-18T09:35:59Z")

</div>

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:**

```auto
--- 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

```

---

<div class="post-metadata">

**Author:** ![csrfr](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/c/ecae2f/32.png) [@csrfr](https://forum.devtalk.com/u/csrfr)\
**Post date:** [27 January 2021 21:01 UTC](https://forum.devtalk.com/t/distributed-services-with-go-failure-with-mutual-tls/861/3 "2021-01-27T21:01:50Z")

</div>

For those that face this…

You have to update two things.

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

```auto
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`

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

```

---

<div class="post-metadata">

**Author:** ![travisjeffery](https://forum.devtalk.com/user_avatar/forum.devtalk.com/travisjeffery/32/525_2.png) [@travisjeffery](https://forum.devtalk.com/u/travisjeffery)\
**Post date:** [28 January 2021 23:52 UTC](https://forum.devtalk.com/t/distributed-services-with-go-failure-with-mutual-tls/861/4 "2021-01-28T23:52:00Z")

</div>

Thanks, I’m looking at fixing this.

---

<div class="post-metadata">

**Author:** ![travisjeffery](https://forum.devtalk.com/user_avatar/forum.devtalk.com/travisjeffery/32/525_2.png) [@travisjeffery](https://forum.devtalk.com/u/travisjeffery)\
**Post date:** [8 February 2021 08:55 UTC](https://forum.devtalk.com/t/distributed-services-with-go-failure-with-mutual-tls/861/5 "2021-02-08T08:55:27Z")

</div>

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