Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable Request.Format #276

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pkg/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ import (
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"github.com/Venafi/vcert/v4/pkg/util"
"github.com/youmark/pkcs8"
"net"
"net/url"
"strings"
"time"

"github.com/Venafi/vcert/v4/pkg/verror"
"github.com/Venafi/vcert/v4/pkg/util"
"github.com/youmark/pkcs8"

"reflect"
"sort"

"github.com/Venafi/vcert/v4/pkg/verror"
)

// EllipticCurve represents the types of supported elliptic curves
Expand Down Expand Up @@ -211,6 +213,7 @@ type Request struct {
Location *Location
ValidityHours int
IssuerHint string
Format string
}

//SSH Certificate structures
Expand Down
11 changes: 7 additions & 4 deletions pkg/venafi/tpp/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,12 @@ func (c *Connector) RetrieveCertificate(req *certificate.Request) (certificates

includeChain := req.ChainOption != certificate.ChainOptionIgnore
rootFirstOrder := includeChain && req.ChainOption == certificate.ChainOptionRootFirst
if req.Format == "" {
if req.KeyType == certificate.KeyTypeRSA {
req.Format = "Base64 (PKCS #8)"
}
req.Format = "base64"
}

if req.PickupID == "" && req.Thumbprint != "" {
// search cert by Thumbprint and fill pickupID
Expand All @@ -1219,15 +1225,12 @@ func (c *Connector) RetrieveCertificate(req *certificate.Request) (certificates

certReq := certificateRetrieveRequest{
CertificateDN: req.PickupID,
Format: "base64",
RootFirstOrder: rootFirstOrder,
IncludeChain: includeChain,
Format: req.Format,
}
if req.CsrOrigin == certificate.ServiceGeneratedCSR || req.FetchPrivateKey {
certReq.IncludePrivateKey = true
if req.KeyType == certificate.KeyTypeRSA {
certReq.Format = "Base64 (PKCS #8)"
}
certReq.Password = req.KeyPassword
}

Expand Down