Skip to content

Commit

Permalink
Fix bug for registry names with ports
Browse files Browse the repository at this point in the history
Signed-off-by: Shiwei Zhang <shizh@microsoft.com>
  • Loading branch information
shizhMSFT committed Sep 1, 2020
1 parent d8bdff0 commit 3dc7623
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/nv2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func main() {
app := &cli.App{
Name: "nv2",
Usage: "Notary V2 - Prototype",
Version: "0.3.1",
Version: "0.3.2",
Authors: []*cli.Author{
{
Name: "Shiwei Zhang",
Expand Down
2 changes: 1 addition & 1 deletion pkg/signature/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *Scheme) SignRaw(signerID string, content []byte) (string, error) {

signed, sig, err := signer.Sign(EncodeSegment(content))
if err != nil {
return "", nil
return "", err
}

return strings.Join([]string{
Expand Down
4 changes: 3 additions & 1 deletion pkg/signature/x509/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ func verifyReferences(seg string, cert *x509.Certificate) error {
roots := x509.NewCertPool()
roots.AddCert(cert)
for _, reference := range claims.Manifest.References {
domain := strings.SplitN(reference, "/", 2)[0]
domain = strings.SplitN(domain, ":", 2)[0]
if _, err := cert.Verify(x509.VerifyOptions{
DNSName: strings.SplitN(reference, "/", 2)[0],
DNSName: domain,
Roots: roots,
}); err != nil {
return err
Expand Down
4 changes: 3 additions & 1 deletion pkg/tuf/local/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ func verifyReferences(raw []byte, cert *x509.Certificate) error {
roots := x509.NewCertPool()
roots.AddCert(cert)
for reference := range targets.Targets {
domain := strings.SplitN(reference, "/", 2)[0]
domain = strings.SplitN(domain, ":", 2)[0]
if _, err := cert.Verify(x509.VerifyOptions{
DNSName: strings.SplitN(reference, "/", 2)[0],
DNSName: domain,
Roots: roots,
}); err != nil {
return err
Expand Down

0 comments on commit 3dc7623

Please sign in to comment.