From c1b3507df7114fba929c3f903e55c9787eb2d623 Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Wed, 4 Jan 2023 10:32:56 -0500 Subject: blah --- registry/registry.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'registry/registry.go') diff --git a/registry/registry.go b/registry/registry.go index 7b47d73..58bf439 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -207,16 +207,20 @@ func (r *Registry) Inbox(name string, req *http.Request) error { pubKey := iter.Get() pemProp := pubKey.GetW3IDSecurityV1PublicKeyPem() pemStr := pemProp.Get() - pemStr = strings.ReplaceAll(pemStr, "\n", "") logger.With("keyId", keyId).With("pem", pemStr).Debugf("extracted pem") pemObj, _ := pem.Decode([]byte(pemStr)) if pemObj == nil { return fmt.Errorf("no PEM block found") } + if pemObj.Type != "PUBLIC KEY" { + return fmt.Errorf("no public key found in PEM block") + } + decodedKey, err := x509.ParsePKCS1PublicKey(pemObj.Bytes) if err != nil { return err } + logger.With("keyId", keyId).With("pem", pemStr).Debugf("got %T", decodedKey) algo := httpsig.RSA_SHA256 return verifier.Verify(decodedKey, algo) } -- cgit v1.2.3