extract RSA public key from certificate
(certPem []byte)
| 34 | |
| 35 | // extract RSA public key from certificate |
| 36 | func getPublicKeyFromCert(certPem []byte) []byte { |
| 37 | block, _ := pem.Decode(certPem) |
| 38 | crt, err := x509.ParseCertificate(block.Bytes) |
| 39 | if err != nil { |
| 40 | panic(err) |
| 41 | } |
| 42 | pubKey, err := x509.MarshalPKIXPublicKey(crt.PublicKey.(*rsa.PublicKey)) |
| 43 | if err != nil { |
| 44 | panic(err) |
| 45 | } |
| 46 | return pem.EncodeToMemory(&pem.Block{Type: "PUBLIC KEY", Bytes: pubKey}) |
| 47 | } |
| 48 | |
| 49 | // generate and sign RSA certificates with given CA |
| 50 | // see: https://fale.io/blog/2017/06/05/create-a-pki-in-golang/ |
no test coverage detected