MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / CreateDerivedCA

Method CreateDerivedCA

pkg/certs/certs.go:358–374  ·  view source on GitHub ↗

CreateDerivedCA create a new CA derived from the certificate in the keypair

(commonName string, organizationalUnit string)

Source from the content-addressed store, hash-verified

356// CreateDerivedCA create a new CA derived from the certificate in the
357// keypair
358func (pair *KeyPair) CreateDerivedCA(commonName string, organizationalUnit string) (*KeyPair, error) {
359 certificate, err := pair.ParseCertificate()
360 if err != nil {
361 return nil, err
362 }
363
364 key, err := pair.ParseECPrivateKey()
365 if err != nil {
366 return nil, err
367 }
368
369 certificateDuration := getCertificateDuration()
370 notBefore := time.Now().Add(time.Minute * -5)
371 notAfter := notBefore.Add(certificateDuration)
372
373 return createCAWithValidity(notBefore, notAfter, certificate, key, commonName, organizationalUnit)
374}
375
376// CreateRootCA generates a CA returning its keys
377func CreateRootCA(commonName string, organizationalUnit string) (*KeyPair, error) {

Callers 1

certs_test.goFile · 0.80

Calls 4

ParseCertificateMethod · 0.95
ParseECPrivateKeyMethod · 0.95
getCertificateDurationFunction · 0.85
createCAWithValidityFunction · 0.85

Tested by

no test coverage detected