From 560929efaa0f756ac7a7355c087b8f0a16a12a0d Mon Sep 17 00:00:00 2001 From: Gibheer Date: Wed, 1 Apr 2015 21:17:04 +0200 Subject: add crl url support With this option added, it is now possible to add crl urls to the certificates. --- certificate.go | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/certificate.go b/certificate.go index 58f42b1..acb4b5a 100644 --- a/certificate.go +++ b/certificate.go @@ -85,6 +85,7 @@ type ( caPath string // path to the ca file if isCA is false keyUsage string // comma separated list of key usages extKeyUsage string // comma separated list of extended key usages + crlUrl string // comma separated list of crl urls } ) @@ -121,6 +122,11 @@ func InitFlagCert(cmd *Command) { "ext-key-usage", "", "comma separated list of extended key usage flags", ) + cmd.Flags().StringVar( + &flagContainer.certGeneration.crlUrl, + "crl-url", "", + "comma separated list where crl lists can be found", + ) } // create a certificate @@ -168,7 +174,21 @@ func checkCertFlags() error { return err } } - // parse the key usage string + + if err := convertCertKeyUsage(); err != nil { + return err + } + if err := convertCertExtKeyUsage(); err != nil { + return err + } + if err := convertCertCrlUrl(); err != nil { + return err + } + return nil +} + +// parse the key usage string +func convertCertKeyUsage() error { if keyUstr := flagContainer.certGeneration.keyUsage; keyUstr != "" { keyUarr := strings.Split(keyUstr, ",") var keyUresult x509.KeyUsage @@ -181,7 +201,11 @@ func checkCertFlags() error { } FlagCertificateGeneration.KeyUsage = keyUresult } - // parse the extended key usage flags + return nil +} + +// parse the extended key usage flags +func convertCertExtKeyUsage() error { if eKeyUstr := flagContainer.certGeneration.extKeyUsage; eKeyUstr != "" { eKeyUarr := strings.Split(eKeyUstr, ",") eKeyUResult := make([]x509.ExtKeyUsage, 0) @@ -197,6 +221,14 @@ func checkCertFlags() error { return nil } +// parse the crl urls +func convertCertCrlUrl() error { + if str := flagContainer.certGeneration.crlUrl; str != "" { + FlagCertificateGeneration.CRLUrls = strings.Split(str, ",") + } + return nil +} + // add flag to load certificate sign request func InitFlagCSR(cmd *Command) { cmd.Flags().StringVar(&flagContainer.signRequestPath, "csr-path", "", "path to the certificate sign request") -- cgit v1.2.3-70-g09d2