Golang: certificate verification was signed using private key

I am migrating an application from php and cannot figure out how to verify the SSL certificate signed by our private key for a given server.

In php, it's simple: openssl_x509_check_private_key ($ cert, $ pkey)

I can check the start and end dates and validity for the host, but I don't see a way to do this.

+3


source to share


1 answer


The docs for openssl_x509_check_private_key don't actually say what the arguments are. I will assume they are either filenames for PEM encoded data or directly PEM encoded data (strings).

In this case, you can simply call tls.LoadX509KeyPair or tls.X509KeyPair, which will check if the certificate and key match.



Check out the tls.X509KeyPair source if you're interested in a low-level API that does the actual validation (search for x509.ParseCertificate).

0


source







All Articles