nats-server icon indicating copy to clipboard operation
nats-server copied to clipboard

Hiding TLS certs

Open alexey-sderzhikov opened this issue 3 years ago • 11 comments
trafficstars

Hi!

I am developing app with microservice arch. Microservices push and consume messages with NATS. In feature i will deploy my app on customer's hardware, and i must be sure, that the customer will not be able to replace my microservices with their own and modify messages. For this purpose i use TLS connection and embed certificates in my microservices and hide their from customer. But NATS takes TLS certificates explicit.

How can i hide TLS certificates? Thanks for answer!

alexey-sderzhikov avatar Sep 08 '22 08:09 alexey-sderzhikov

Are you talking about the server or a client app in terms of "takes TLS certificates explicit"?

derekcollison avatar Sep 08 '22 13:09 derekcollison

About server

alexey-sderzhikov avatar Sep 08 '22 13:09 alexey-sderzhikov

There are various approaches, looping in a few folks who should be able to help.

derekcollison avatar Sep 08 '22 14:09 derekcollison

Hi @alexey-sderzhikov. Just to confirm, only the microservice is being deployed on the customer's hardware and not the server, correct? And the goal is that you want a client connection to not have to read the certs from disk, but it should be embedded in the application code (which presumably is compiled/byte code)?

bruth avatar Sep 08 '22 19:09 bruth

Hi! Not exactly, microcervices(clients) and NATS(server) will deployed on customer's hardware as well. Hide certs into compiled clients no problem for me, because i will deploy app with docker images, and can embed certs on build stage in Dockerfile. The goal is embed certs into NATS, like i did for my microservices.

alexey-sderzhikov avatar Sep 09 '22 07:09 alexey-sderzhikov

You can embed nats server in your own code and then configure it that way.

However, be aware that embedding keys in your code is not secure typically unless you go to great lengths.

ripienaar avatar Sep 09 '22 07:09 ripienaar

I am not sure I understood, you mean I can modify NATS source code, embed my certs and build my own binary?

alexey-sderzhikov avatar Sep 09 '22 08:09 alexey-sderzhikov

No need to modify the source. You can start the server in a go routine of your own code and supply certs to it however you like using a go TLSconfig.

ripienaar avatar Sep 09 '22 08:09 ripienaar

Hm, i.e. i need to make my own main.go where i will configure opts with TLSconfig paste them into server creating and then call server.Run() like in main.go?

alexey-sderzhikov avatar Sep 09 '22 08:09 alexey-sderzhikov

Correct. There is a helper function to generate the *tls.Config as well.

bruth avatar Sep 09 '22 09:09 bruth

I think it will work, cool, thanks!!!!

alexey-sderzhikov avatar Sep 09 '22 09:09 alexey-sderzhikov