Get pem data easier
This commit is contained in:
parent
4d057cdb31
commit
80469dfbd1
16
cert.go
16
cert.go
@ -17,9 +17,10 @@ type CertGen struct {
|
|||||||
certPem, keyPem []byte
|
certPem, keyPem []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ca *CertGen) GetTlsLeaf() tls.Certificate {
|
func (ca *CertGen) GetTlsLeaf() tls.Certificate { return ca.tlsCert }
|
||||||
return ca.tlsCert
|
|
||||||
}
|
func (ca *CertGen) GetCertPem() []byte { return ca.certPem }
|
||||||
|
func (ca *CertGen) GetKeyPem() []byte { return ca.keyPem }
|
||||||
|
|
||||||
func (ca *CertGen) generatePem() error {
|
func (ca *CertGen) generatePem() error {
|
||||||
a := new(bytes.Buffer)
|
a := new(bytes.Buffer)
|
||||||
@ -58,11 +59,16 @@ func LoadCertGen(certBytes, keyBytes []byte) (*CertGen, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
leaf := TlsLeaf(&pair)
|
leaf := TlsLeaf(&pair)
|
||||||
return &CertGen{
|
gen := &CertGen{
|
||||||
tlsCert: pair,
|
tlsCert: pair,
|
||||||
cert: leaf,
|
cert: leaf,
|
||||||
key: pair.PrivateKey,
|
key: pair.PrivateKey,
|
||||||
certBytes: certBytes,
|
certBytes: certBytes,
|
||||||
keyBytes: keyBytes,
|
keyBytes: keyBytes,
|
||||||
}, nil
|
}
|
||||||
|
err = gen.generatePem()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return gen, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user