Skip to content

Commit

Permalink
fix pkg path
Browse files Browse the repository at this point in the history
  • Loading branch information
eyalle committed Mar 23, 2023
1 parent ca77a89 commit ddfb2d6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
35 changes: 34 additions & 1 deletion pkg/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ type Location struct {
Replace bool
}

type CertificateFormat int

const (
CertFormatNotSet CertificateFormat = iota
CertFormatBase64
CertFormatBase64PKCS8
CertFormatDER
CertFormatJKS
CertFormatPKCS7
CertFormatPKCS12
)

// Request contains data needed to generate a certificate request
// CSR is a PEM-encoded Certificate Signing Request
type Request struct {
Expand Down Expand Up @@ -213,7 +225,7 @@ type Request struct {
Location *Location
ValidityHours int
IssuerHint string
Format string
Format CertificateFormat
}

//SSH Certificate structures
Expand Down Expand Up @@ -793,3 +805,24 @@ func FindNewestCertificateWithSans(certificates []*CertificateInfo, sans_ *Sans)
// fail, since no valid certificate was found at this point
return nil, verror.NoCertificateFoundError
}

func (f CertificateFormat) String() string {
switch f {
case CertFormatBase64PKCS8:
return "base64 (pkcs #8)"
case CertFormatDER:
return "der"
case CertFormatJKS:
return "jks"
case CertFormatPKCS7:
return "pkcs #7"
case CertFormatPKCS12:
return "pkcs #12"
case CertFormatBase64:
fallthrough
case CertFormatNotSet:
fallthrough
default:
return "base64"
}
}
10 changes: 6 additions & 4 deletions pkg/venafi/tpp/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -1203,10 +1203,10 @@ func (c *Connector) RetrieveCertificate(req *certificate.Request) (certificates
rootFirstOrder := includeChain && req.ChainOption == certificate.ChainOptionRootFirst

// if Request doesn't contain a Format, use defaults
if req.Format == "" {
req.Format = "base64"
if req.Format.String() == "" {
req.Format = certificate.CertFormatBase64
if req.KeyType == certificate.KeyTypeRSA {
req.Format = "Base64 (PKCS #8)"
req.Format = certificate.CertFormatBase64PKCS8
}
}

Expand All @@ -1229,8 +1229,10 @@ func (c *Connector) RetrieveCertificate(req *certificate.Request) (certificates
CertificateDN: req.PickupID,
RootFirstOrder: rootFirstOrder,
IncludeChain: includeChain,
Format: req.Format,
Format: req.Format.String(),
}

fmt.Println("\n\n", certReq)
if req.CsrOrigin == certificate.ServiceGeneratedCSR || req.FetchPrivateKey {
certReq.IncludePrivateKey = true
certReq.Password = req.KeyPassword
Expand Down

0 comments on commit ddfb2d6

Please sign in to comment.