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.
- a CA root cer file
- a Server cer file
- 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:
- Generate a CA Certificate
- Generate a Server key
- Sign the Server key with the CA certificate
- Add the CA Certificate to the client's
tls.Config
RootCAs
- Set up the server's
tls.Config
with the Server key and signed certificate.