Hi,
What I have:
- tls-certificate (x.509 format, pem encoded)
- within the tls-certificate -> public-key (rsa encrypted)
- corresponding private-key (pem encoded, rsa encrypted)
What I want:
- validate pem encoded private-keys // (something like 'openssl rsa -in client.key -check' )
- validate key-pair (if private-key is matching certificate) // (something like is key matching certificate running -> 'openssl x509 -noout -modulus -in client.cert | openssl md5' == 'openssl rsa -noout -modulus -in PRIVATEKEY.key | openssl md5')
What I tried:
func CheckKeyPair(clientcert, key string) error {
block, _ := pem.Decode([]byte(clientcert)) // decode pem encoded tls certificate
cert,_ := x509.ParseCertificate(block.Bytes) // parse certificate (get type x509.*Certificate)
fmt.Println(reflect.TypeOf(cert.PublicKey)) // print parsed public-key from certificate (get type *rsa.PublicKey)
return nil
}
I fill this function with an the tls-certificate (type string) and private-key (type string).
I've already started several experiments. That's why I haven't posted my mischief yet.
Does anyone know how to move on?
Best,
A