MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / getPublicKeyFromCert

Function getPublicKeyFromCert

IceFireDB-SQLProxy/pkg/mysql/server/ssl.go:36–47  ·  view source on GitHub ↗

extract RSA public key from certificate

(certPem []byte)

Source from the content-addressed store, hash-verified

34
35// extract RSA public key from certificate
36func 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/

Callers 1

NewDefaultServerFunction · 0.70

Calls 1

DecodeMethod · 0.45

Tested by

no test coverage detected