Skip to content

Commit

Permalink
fix example to explicitly set port for gRPC call (#732)
Browse files Browse the repository at this point in the history
* fix example to explicitly set port for gRPC call

Signed-off-by: Bob Callaway <bcallaway@google.com>

* switch from RSA to ECDSA

Signed-off-by: Bob Callaway <bcallaway@google.com>
  • Loading branch information
bobcallaway committed Aug 10, 2022
1 parent 7764cdb commit 9c0a2e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/request-certificate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
request-certificate
9 changes: 6 additions & 3 deletions examples/request-certificate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (
)

// Some of this is just ripped from cosign
func GetCert(signer *signature.RSAPKCS1v15SignerVerifier, fc fulciopb.CAClient, oidcIssuer string, oidcClientID string) (*fulciopb.SigningCertificate, error) {
func GetCert(signer *signature.ECDSASignerVerifier, fc fulciopb.CAClient, oidcIssuer string, oidcClientID string) (*fulciopb.SigningCertificate, error) {

tok, err := oauthflow.OIDConnect(oidcIssuer, oidcClientID, "", "", oauthflow.DefaultIDTokenGetter)
if err != nil {
Expand Down Expand Up @@ -85,18 +85,21 @@ func NewClient(fulcioURL string) (fulciopb.CAClient, error) {
return nil, err
}
dialOpt := grpc.WithTransportCredentials(insecure.NewCredentials())
hostWithPort := fmt.Sprintf("%s:80", fulcioServer.Host)
if fulcioServer.Scheme == "https" {
dialOpt = grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{}))
hostWithPort = fmt.Sprintf("%s:443", fulcioServer.Host)
}
conn, err := grpc.Dial(fulcioServer.Host, dialOpt)

conn, err := grpc.Dial(hostWithPort, dialOpt)
if err != nil {
return nil, err
}
return fulciopb.NewCAClient(conn), nil
}

func main() {
signer, _, err := signature.NewDefaultRSAPKCS1v15SignerVerifier()
signer, _, err := signature.NewDefaultECDSASignerVerifier()
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 9c0a2e7

Please sign in to comment.