TLS with selfsigned certificate

Kyle, is correct. This tool will do what you want and it simplifies the entire process:

https://github.com/deckarep/EasyCert/releases (only OSX is supported since it uses the openssl tool internally)

and the source:

https://github.com/deckarep/EasyCert

Basically with this tool it will generate a bundle of files but you will need the three that it outputs when it's done.

  1. a CA root cer file
  2. a Server cer file
  3. a Server key file

It finally worked with the go built in x509.CreateCertificate, the problem was that I did not set the IsCA:true flag, I only set the x509.KeyUsageCertSign which made creating the self signed certificate work, but crashed while verifying the cert chain.


The problem is that you need a CA certificate in the server-side config, and this CA must have signed the server's certificate.

I have written some Go code that will generate a CA certificate, but it hasn't been reviewed by anyone and is mostly a toy for playing around with client certs. The safest bet is probably to use openssl ca to generate and sign the certificate. The basic steps will be:

  1. Generate a CA Certificate
  2. Generate a Server key
  3. Sign the Server key with the CA certificate
  4. Add the CA Certificate to the client's tls.Config RootCAs
  5. Set up the server's tls.Config with the Server key and signed certificate.

Tags:

Ssl

Go