-
Notifications
You must be signed in to change notification settings - Fork 565
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
continued sign refacc #1098
continued sign refacc #1098
Changes from 1 commit
865342a
764ef20
ad6188e
5a1540a
3f5bf27
a99d528
29b2e61
04cc55f
66c3a2c
5116c1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ import ( | |
"github.com/sigstore/cosign/cmd/cosign/cli/fulcio/fulcioverifier" | ||
"github.com/sigstore/cosign/cmd/cosign/cli/options" | ||
icos "github.com/sigstore/cosign/internal/pkg/cosign" | ||
ifulcio "github.com/sigstore/cosign/internal/pkg/cosign/fulcio" | ||
irekor "github.com/sigstore/cosign/internal/pkg/cosign/rekor" | ||
"github.com/sigstore/cosign/pkg/cosign" | ||
"github.com/sigstore/cosign/pkg/cosign/pivkey" | ||
"github.com/sigstore/cosign/pkg/cosign/pkcs11key" | ||
|
@@ -212,16 +214,9 @@ func signDigest(ctx context.Context, digest name.Digest, payload []byte, ko KeyO | |
s = &icos.PayloadSigner{ | ||
PayloadSigner: sv, | ||
} | ||
s = &icos.FulcioSignerWrapper{ | ||
Cert: sv.Cert, | ||
Chain: sv.Chain, | ||
Inner: s, | ||
} | ||
s = ifulcio.NewSigner(s, sv.Cert, sv.Chain) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A few things about this line don't sit right with me:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes :p "TODO:" |
||
if ShouldUploadToTlog(ctx, digest, force, ko.RekorURL) { | ||
s = &icos.RekorSignerWrapper{ | ||
Inner: s, | ||
RekorURL: ko.RekorURL, | ||
} | ||
s = irekor.NewSigner(s, ko.RekorURL) | ||
} | ||
|
||
ociSig, _, err := s.Sign(ctx, bytes.NewReader(payload)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,30 +12,31 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cosign | ||
package fulcio | ||
|
||
import ( | ||
"context" | ||
"crypto" | ||
"io" | ||
|
||
"github.com/sigstore/cosign/internal/pkg/cosign" | ||
"github.com/sigstore/cosign/pkg/oci" | ||
"github.com/sigstore/cosign/pkg/oci/static" | ||
) | ||
|
||
// FulcioSignerWrapper still needs to actually upload keys to Fulcio and receive | ||
// SignerWrapper still needs to actually upload keys to Fulcio and receive | ||
// the resulting `Cert` and `Chain`, which are added to the returned `oci.Signature` | ||
type FulcioSignerWrapper struct { | ||
Inner Signer | ||
type SignerWrapper struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be private now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
inner cosign.Signer | ||
|
||
Cert, Chain []byte | ||
cert, chain []byte | ||
} | ||
|
||
var _ Signer = (*FulcioSignerWrapper)(nil) | ||
var _ cosign.Signer = (*SignerWrapper)(nil) | ||
|
||
// Sign implements `Signer` | ||
func (fs *FulcioSignerWrapper) Sign(ctx context.Context, payload io.Reader) (oci.Signature, crypto.PublicKey, error) { | ||
sig, pub, err := fs.Inner.Sign(ctx, payload) | ||
// Sign implements `cosign.Signer` | ||
func (fs *SignerWrapper) Sign(ctx context.Context, payload io.Reader) (oci.Signature, crypto.PublicKey, error) { | ||
sig, pub, err := fs.inner.Sign(ctx, payload) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really grok why this is wrapping any Signer instead of having a specific Signer implementation embedded here. Can this truly be composed with other Signer implementations arbitrarily? What other compositions make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not quite arbitrarily but we made the |
||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
@@ -51,7 +52,7 @@ func (fs *FulcioSignerWrapper) Sign(ctx context.Context, payload io.Reader) (oci | |
|
||
// TODO(dekkagaijin): move the fulcio SignerVerififer logic here | ||
|
||
opts := []static.Option{static.WithCertChain(fs.Cert, fs.Chain)} | ||
opts := []static.Option{static.WithCertChain(fs.cert, fs.chain)} | ||
|
||
// Copy over the other attributes: | ||
if annotations, err := sig.Annotations(); err != nil { | ||
|
@@ -77,3 +78,12 @@ func (fs *FulcioSignerWrapper) Sign(ctx context.Context, payload io.Reader) (oci | |
|
||
return newSig, pub, nil | ||
} | ||
|
||
// NewSigner returns a *SignerWrapper which signs and uploads the given payload to Fulcio. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment could use work :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. your FACE could use work |
||
func NewSigner(inner cosign.Signer, cert, chain []byte) *SignerWrapper { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return the interface There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
return &SignerWrapper{ | ||
inner: inner, | ||
cert: cert, | ||
chain: chain, | ||
} | ||
} |
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.
I'd move the payload signer as well.
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.
roger