-
Notifications
You must be signed in to change notification settings - Fork 86
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
feat: blob sign
command
#1128
base: main
Are you sure you want to change the base?
feat: blob sign
command
#1128
Conversation
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1128 +/- ##
==========================================
+ Coverage 70.79% 72.50% +1.70%
==========================================
Files 48 50 +2
Lines 2945 3139 +194
==========================================
+ Hits 2085 2276 +191
- Misses 668 670 +2
- Partials 192 193 +1 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
return err | ||
} | ||
signaturePath := signatureFilepath(cmdOpts.signatureDirectory, cmdOpts.blobPath, cmdOpts.SignatureFormat) | ||
fmt.Printf("Writing signature to file %s\n", signaturePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to be a debug log?
} | ||
if !isRoot { | ||
return notation.SignBlobOptions{}, fmt.Errorf("certificate from %q is not a root certificate. Expecting single x509 root certificate in PEM or DER format from the file", opts.tsaRootCertificatePath) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line.
rootCerts, err := corex509.ReadCertificateFile(opts.tsaRootCertificatePath) | ||
if err != nil { | ||
return notation.SignBlobOptions{}, err | ||
} | ||
if len(rootCerts) == 0 { | ||
return notation.SignBlobOptions{}, fmt.Errorf("cannot find any certificate from %q. Expecting single x509 root certificate in PEM or DER format from the file", opts.tsaRootCertificatePath) | ||
} | ||
if len(rootCerts) > 1 { | ||
return notation.SignBlobOptions{}, fmt.Errorf("found more than one certificates from %q. Expecting single x509 root certificate in PEM or DER format from the file", opts.tsaRootCertificatePath) | ||
} | ||
tsaRootCert := rootCerts[0] | ||
isRoot, err := nx509.IsRootCertificate(tsaRootCert) | ||
if err != nil { | ||
return notation.SignBlobOptions{}, fmt.Errorf("failed to check root certificate with error: %w", err) | ||
} | ||
if !isRoot { | ||
return notation.SignBlobOptions{}, fmt.Errorf("certificate from %q is not a root certificate. Expecting single x509 root certificate in PEM or DER format from the file", opts.tsaRootCertificatePath) | ||
|
||
} | ||
rootCAs := x509.NewCertPool() | ||
rootCAs.AddCert(tsaRootCert) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to function for preparing TSA root cert and can be shared in both OCI signing and blob signing command to reduce repeated code.
This PR adds
notation blob sign
command with E2E tests.It's an implementation of spec: https://github.com/notaryproject/notation/blob/main/specs/commandline/blob.md#notation-blob-sign