From 38d400649cdff74a95b96474a78ec2a37c9ec0f2 Mon Sep 17 00:00:00 2001 From: Wim Date: Fri, 10 Jul 2020 23:17:17 +0200 Subject: [PATCH] Match on prefix for certificates This also gives support for signing with ssh certificates - ssh-rsa-cert-v01@openssh.com - ssh-ed25519-cert-v01@openssh.com --- httpsig.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/httpsig.go b/httpsig.go index ed55219..1a6b954 100644 --- a/httpsig.go +++ b/httpsig.go @@ -11,6 +11,7 @@ import ( "crypto" "fmt" "net/http" + "strings" "time" "golang.org/x/crypto/ssh" @@ -229,10 +230,10 @@ func NewSSHSigner(s ssh.Signer, dAlgo DigestAlgorithm, headers []string, scheme } func getSSHAlgorithm(pkType string) Algorithm { - switch pkType { - case sshPrefix + "-" + ed25519Prefix: + switch { + case strings.HasPrefix(pkType, sshPrefix+"-"+ed25519Prefix): return ED25519 - case sshPrefix + "-" + rsaPrefix: + case strings.HasPrefix(pkType, sshPrefix+"-"+rsaPrefix): return RSA_SHA1 }