From b312b224dd2a1ebc58eac5c087227eefb04adcc1 Mon Sep 17 00:00:00 2001 From: Jesse Peterson Date: Tue, 24 Oct 2023 08:46:12 -0700 Subject: [PATCH 1/2] update README --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a55d117..05a485b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # pkcs7 -[![GoDoc](https://godoc.org/go.mozilla.org/pkcs7?status.svg)](https://godoc.org/go.mozilla.org/pkcs7) -[![Build Status](https://github.com/mozilla-services/pkcs7/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/mozilla-services/pkcs7/actions/workflows/ci.yml?query=branch%3Amaster+event%3Apush) +[![Go Reference](https://pkg.go.dev/badge/github.com/smallstep/pkcs7.svg)](https://pkg.go.dev/github.com/smallstep/pkcs7) +[![Build Status](https://github.com/smallstep/pkcs7/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/smallstep/pkcs7/actions/workflows/ci.yml?query=branch%3Amaster+event%3Apush) pkcs7 implements parsing and creating signed and enveloped messages. @@ -16,7 +16,7 @@ import ( "fmt" "os" - "go.mozilla.org/pkcs7" + "github.com/smallstep/pkcs7" ) func SignAndDetach(content []byte, cert *x509.Certificate, privkey *rsa.PrivateKey) (signed []byte, err error) { @@ -66,4 +66,5 @@ func SignAndDetach(content []byte, cert *x509.Certificate, privkey *rsa.PrivateK ## Credits -This is a fork of [fullsailor/pkcs7](https://github.com/fullsailor/pkcs7) + +This is a fork of [mozilla-services/pkcs7](https://github.com/mozilla-services/pkcs7) which, itself, was a fork of [fullsailor/pkcs7](https://github.com/fullsailor/pkcs7). From c4b4dff2aa6df5533e97c1c9dd1dc61f5004ad45 Mon Sep 17 00:00:00 2001 From: Herman Slatman Date: Fri, 27 Oct 2023 15:08:29 +0200 Subject: [PATCH 2/2] Update link to GitHub Actions badge and wrap errors in example --- README.md | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 05a485b..9d94e65 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # pkcs7 [![Go Reference](https://pkg.go.dev/badge/github.com/smallstep/pkcs7.svg)](https://pkg.go.dev/github.com/smallstep/pkcs7) -[![Build Status](https://github.com/smallstep/pkcs7/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/smallstep/pkcs7/actions/workflows/ci.yml?query=branch%3Amaster+event%3Apush) +[![Build Status](https://github.com/smallstep/pkcs7/workflows/CI/badge.svg?query=branch%3Amain+event%3Apush)](https://github.com/smallstep/pkcs7/actions/workflows/ci.yml?query=branch%3Amain+event%3Apush) pkcs7 implements parsing and creating signed and enveloped messages. @@ -22,12 +22,10 @@ import ( func SignAndDetach(content []byte, cert *x509.Certificate, privkey *rsa.PrivateKey) (signed []byte, err error) { toBeSigned, err := NewSignedData(content) if err != nil { - err = fmt.Errorf("Cannot initialize signed data: %s", err) - return + return fmt.Errorf("Cannot initialize signed data: %w", err) } if err = toBeSigned.AddSigner(cert, privkey, SignerInfoConfig{}); err != nil { - err = fmt.Errorf("Cannot add signer: %s", err) - return + return fmt.Errorf("Cannot add signer: %w", err) } // Detach signature, omit if you want an embedded signature @@ -35,28 +33,24 @@ func SignAndDetach(content []byte, cert *x509.Certificate, privkey *rsa.PrivateK signed, err = toBeSigned.Finish() if err != nil { - err = fmt.Errorf("Cannot finish signing data: %s", err) - return + return fmt.Errorf("Cannot finish signing data: %w", err) } // Verify the signature pem.Encode(os.Stdout, &pem.Block{Type: "PKCS7", Bytes: signed}) p7, err := pkcs7.Parse(signed) if err != nil { - err = fmt.Errorf("Cannot parse our signed data: %s", err) - return + return fmt.Errorf("Cannot parse our signed data: %w", err) } // since the signature was detached, reattach the content here p7.Content = content if bytes.Compare(content, p7.Content) != 0 { - err = fmt.Errorf("Our content was not in the parsed data:\n\tExpected: %s\n\tActual: %s", content, p7.Content) - return + return fmt.Errorf("Our content was not in the parsed data:\n\tExpected: %s\n\tActual: %s", content, p7.Content) } if err = p7.Verify(); err != nil { - err = fmt.Errorf("Cannot verify our signed data: %s", err) - return + return fmt.Errorf("Cannot verify our signed data: %w", err) } return signed, nil @@ -64,7 +58,6 @@ func SignAndDetach(content []byte, cert *x509.Certificate, privkey *rsa.PrivateK ``` - ## Credits This is a fork of [mozilla-services/pkcs7](https://github.com/mozilla-services/pkcs7) which, itself, was a fork of [fullsailor/pkcs7](https://github.com/fullsailor/pkcs7).