Skip to content

Commit 0d1fe8c

Browse files
authored
cfca: add pkcs7 signed data facade
1 parent 90fa223 commit 0d1fe8c

9 files changed

+180
-25
lines changed

cfca/pkcs7_envelope_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
type certKeyPair struct {
2424
Certificate *smx509.Certificate
25-
PrivateKey *crypto.PrivateKey
25+
PrivateKey crypto.PrivateKey
2626
}
2727

2828
func createTestSM2Certificate(allCA bool) (certKeyPair, error) {
@@ -64,7 +64,7 @@ func createTestSM2CertificateByIssuer(name string, issuer *certKeyPair, sigAlg x
6464
}
6565
if issuer != nil {
6666
issuerCert = issuer.Certificate
67-
issuerKey = *issuer.PrivateKey
67+
issuerKey = issuer.PrivateKey
6868
}
6969

7070
switch sigAlg {
@@ -106,7 +106,7 @@ func createTestSM2CertificateByIssuer(name string, issuer *certKeyPair, sigAlg x
106106
// pem.Encode(os.Stdout, &pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw})
107107
return &certKeyPair{
108108
Certificate: cert,
109-
PrivateKey: &priv,
109+
PrivateKey: priv,
110110
}, nil
111111
}
112112

@@ -125,12 +125,12 @@ func TestEnvelopeMessage(t *testing.T) {
125125
if err != nil {
126126
t.Fatal(err)
127127
}
128-
_, err = OpenEnvelopedMessage(encrypted[:len(encrypted)-1], cert.Certificate, *cert.PrivateKey)
128+
_, err = OpenEnvelopedMessage(encrypted[:len(encrypted)-1], cert.Certificate, cert.PrivateKey)
129129
if err == nil {
130130
t.Fatalf("expected error when decrypting with wrong key, got nil")
131131
}
132132
// pem.Encode(os.Stdout, &pem.Block{Type: "PKCS7", Bytes: encrypted})
133-
result, err := OpenEnvelopedMessage(encrypted, cert.Certificate, *cert.PrivateKey)
133+
result, err := OpenEnvelopedMessage(encrypted, cert.Certificate, cert.PrivateKey)
134134
if err != nil {
135135
t.Fatalf("cannot Decrypt encrypted result: %v", err)
136136
}
@@ -155,12 +155,12 @@ func TestEnvelopeMessageLegacy(t *testing.T) {
155155
if err != nil {
156156
t.Fatal(err)
157157
}
158-
_, err = OpenEnvelopedMessage(encrypted[:len(encrypted)-1], cert.Certificate, *cert.PrivateKey)
158+
_, err = OpenEnvelopedMessage(encrypted[:len(encrypted)-1], cert.Certificate, cert.PrivateKey)
159159
if err == nil {
160160
t.Fatalf("expected error when decrypting with wrong key, got nil")
161161
}
162162
// pem.Encode(os.Stdout, &pem.Block{Type: "PKCS7", Bytes: encrypted})
163-
result, err := OpenEnvelopedMessageLegacy(encrypted, cert.Certificate, *cert.PrivateKey)
163+
result, err := OpenEnvelopedMessageLegacy(encrypted, cert.Certificate, cert.PrivateKey)
164164
if err != nil {
165165
t.Fatalf("cannot Decrypt encrypted result: %v", err)
166166
}

cfca/pkcs7_sign.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2024 Sun Yimin. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package cfca
6+
7+
import (
8+
"crypto"
9+
10+
"github.com/emmansun/gmsm/pkcs7"
11+
"github.com/emmansun/gmsm/smx509"
12+
)
13+
14+
func signMessage(data []byte, cert *smx509.Certificate, key crypto.PrivateKey, detached bool) ([]byte, error) {
15+
signData, _ := pkcs7.NewSMSignedData(data)
16+
if err := signData.SignWithoutAttr(cert, key, pkcs7.SignerInfoConfig{}); err != nil {
17+
return nil, err
18+
}
19+
if detached {
20+
signData.Detach()
21+
}
22+
return signData.Finish()
23+
}
24+
25+
// SignMessageAttach signs the data with the certificate and private key, returns the signed data in PKCS7 (DER) format.
26+
// This method corresponds to CFCA SADK's cfca.sadk.util.p7SignMessageAttach.
27+
func SignMessageAttach(data []byte, cert *smx509.Certificate, key crypto.PrivateKey) ([]byte, error) {
28+
return signMessage(data, cert, key, false)
29+
}
30+
31+
// VerifyMessageAttach verifies the signed data in PKCS7 (DER) format.
32+
// This method corresponds to CFCA SADK's cfca.sadk.util.p7VerifyMessageAttach.
33+
// If verification fails, an error is returned. otherwise, nil is returned.
34+
func VerifyMessageAttach(p7Der []byte) error {
35+
p7, err := pkcs7.Parse(p7Der)
36+
if err != nil {
37+
return err
38+
}
39+
return p7.Verify()
40+
}
41+
42+
// SignMessageDetach signs the data with the certificate and private key, returns the signed data in PKCS7 (DER) format.
43+
// This method corresponds to CFCA SADK's cfca.sadk.util.p7SignMessageDetach.
44+
func SignMessageDetach(data []byte, cert *smx509.Certificate, key crypto.PrivateKey) ([]byte, error) {
45+
return signMessage(data, cert, key, true)
46+
}
47+
48+
// VerifyMessageDetach verifies the signed data in PKCS7 (DER) format with the given source data.
49+
// This method corresponds to CFCA SADK's cfca.sadk.util.p7VerifyMessageDetach.
50+
// If verification fails, an error is returned. otherwise, nil is returned.
51+
func VerifyMessageDetach(p7Der, sourceData []byte) error {
52+
p7, err := pkcs7.Parse(p7Der)
53+
if err != nil {
54+
return err
55+
}
56+
p7.Content = sourceData
57+
return p7.Verify()
58+
}

cfca/pkcs7_sign_test.go

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Copyright 2024 Sun Yimin. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package cfca
6+
7+
import (
8+
"encoding/base64"
9+
"testing"
10+
)
11+
12+
func TestSignMessageAttach(t *testing.T) {
13+
_, err := SignMessageAttach(nil, nil, nil)
14+
if err == nil {
15+
t.Fatalf("SignMessageAttach() error = %v, wantErr %v", err, true)
16+
}
17+
pair, err := createTestSM2Certificate(false)
18+
if err != nil {
19+
t.Fatal(err)
20+
}
21+
_, err = SignMessageAttach([]byte("test"), pair.Certificate, nil)
22+
if err == nil {
23+
t.Fatalf("SignMessageAttach() error = %v, wantErr %v", err, true)
24+
}
25+
p7, err := SignMessageAttach([]byte("test"), pair.Certificate, pair.PrivateKey)
26+
if err != nil {
27+
t.Fatal(err)
28+
}
29+
lastByte := p7[len(p7)-1]
30+
p7[len(p7)-1] = 0
31+
err = VerifyMessageAttach(p7)
32+
if err == nil {
33+
t.Fatalf("VerifyMessageAttach() error = %v, wantErr %v", err, true)
34+
}
35+
p7[len(p7)-1] = lastByte
36+
err = VerifyMessageAttach(p7)
37+
if err != nil {
38+
t.Fatal(err)
39+
}
40+
41+
p7, _ = base64.StdEncoding.DecodeString(sadkSignedData)
42+
err = VerifyMessageAttach(p7)
43+
if err != nil {
44+
t.Fatal(err)
45+
}
46+
}
47+
48+
func TestSignMessageDetach(t *testing.T) {
49+
_, err := SignMessageDetach(nil, nil, nil)
50+
if err == nil {
51+
t.Fatalf("SignMessageAttach() error = %v, wantErr %v", err, true)
52+
}
53+
pair, err := createTestSM2Certificate(false)
54+
if err != nil {
55+
t.Fatal(err)
56+
}
57+
_, err = SignMessageDetach([]byte("test"), pair.Certificate, nil)
58+
if err == nil {
59+
t.Fatalf("SignMessageAttach() error = %v, wantErr %v", err, true)
60+
}
61+
p7, err := SignMessageDetach([]byte("test"), pair.Certificate, pair.PrivateKey)
62+
if err != nil {
63+
t.Fatal(err)
64+
}
65+
lastByte := p7[len(p7)-1]
66+
p7[len(p7)-1] = 0
67+
err = VerifyMessageDetach(p7, []byte("test"))
68+
if err == nil {
69+
t.Fatalf("VerifyMessageAttach() error = %v, wantErr %v", err, true)
70+
}
71+
p7[len(p7)-1] = lastByte
72+
err = VerifyMessageDetach(p7, []byte("test"))
73+
if err != nil {
74+
t.Fatal(err)
75+
}
76+
err = VerifyMessageDetach(p7, []byte("test 1"))
77+
if err == nil || err.Error() != "x509: SM2 verification failure" {
78+
t.Fatalf("VerifyMessageAttach() error = %v, wantErr %v", err, true)
79+
}
80+
err = VerifyMessageDetach(p7, nil)
81+
if err == nil || err.Error() != "x509: SM2 verification failure" {
82+
t.Fatalf("VerifyMessageAttach() error = %v, wantErr %v", err, true)
83+
}
84+
85+
p7, _ = base64.StdEncoding.DecodeString(sadkSignedDataDetach)
86+
err = VerifyMessageDetach(p7, []byte("Hello Secret World!"))
87+
if err != nil {
88+
t.Fatal(err)
89+
}
90+
}
91+
92+
var sadkSignedData = "MIICgAYKKoEcz1UGAQQCAqCCAnAwggJsAgEBMQ4wDAYIKoEcz1UBgxEFADAjBgoqgRzPVQYBBAIBoBUEE0hlbGxvIFNlY3JldCBXb3JsZCGgggGNMIIBiTCCAS+gAwIBAgIFAKncGpAwCgYIKoEcz1UBg3UwKTEQMA4GA1UEChMHQWNtZSBDbzEVMBMGA1UEAxMMRWRkYXJkIFN0YXJrMB4XDTI0MTExOTAwMTIyNVoXDTI1MTExOTAwMTIyNlowJTEQMA4GA1UEChMHQWNtZSBDbzERMA8GA1UEAxMISm9uIFNub3cwWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAATYcgrHXJmFO1/t/9WQ6GkCW6D0yDyd2ya5wRXjVAU08I9Oo6k99jB2MPauCn64W81APRCPHLlwWOtuIsmSmQhjo0gwRjAOBgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUHAwQwHwYDVR0jBBgwFoAUyBfYaeGJxaf9ST9aCRgotC+MwvwwCgYIKoEcz1UBg3UDSAAwRQIgRaF0PA74cCYKeu8pZ4VDQti+rE283Hq/tGXzXUzOWKUCIQDl3z1boZxtRscbnOGOXg1NY+yoY2lz5b63kGOTkn/SxzGBoDCBnQIBATAyMCkxEDAOBgNVBAoTB0FjbWUgQ28xFTATBgNVBAMTDEVkZGFyZCBTdGFyawIFAKncGpAwDAYIKoEcz1UBgxEFADANBgkqgRzPVQGCLQEFAARHMEUCIQCl145xtYc7QWTymATxUGbLfF1mlPlyMoIKSp9alu14UQIgQSV/Ll3yYCyXSNxhPelz8Nsbxopky+Pt56Al54rv3p0="
93+
var sadkSignedDataDetach = "MIICaQYKKoEcz1UGAQQCAqCCAlkwggJVAgEBMQ4wDAYIKoEcz1UBgxEFADAMBgoqgRzPVQYBBAIBoIIBjTCCAYkwggEvoAMCAQICBQCp3BqQMAoGCCqBHM9VAYN1MCkxEDAOBgNVBAoTB0FjbWUgQ28xFTATBgNVBAMTDEVkZGFyZCBTdGFyazAeFw0yNDExMTkwMDEyMjVaFw0yNTExMTkwMDEyMjZaMCUxEDAOBgNVBAoTB0FjbWUgQ28xETAPBgNVBAMTCEpvbiBTbm93MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE2HIKx1yZhTtf7f/VkOhpAlug9Mg8ndsmucEV41QFNPCPTqOpPfYwdjD2rgp+uFvNQD0Qjxy5cFjrbiLJkpkIY6NIMEYwDgYDVR0PAQH/BAQDAgWgMBMGA1UdJQQMMAoGCCsGAQUFBwMEMB8GA1UdIwQYMBaAFMgX2GnhicWn/Uk/WgkYKLQvjML8MAoGCCqBHM9VAYN1A0gAMEUCIEWhdDwO+HAmCnrvKWeFQ0LYvqxNvNx6v7Rl811MzlilAiEA5d89W6GcbUbHG5zhjl4NTWPsqGNpc+W+t5Bjk5J/0scxgaAwgZ0CAQEwMjApMRAwDgYDVQQKEwdBY21lIENvMRUwEwYDVQQDEwxFZGRhcmQgU3RhcmsCBQCp3BqQMAwGCCqBHM9VAYMRBQAwDQYJKoEcz1UBgi0BBQAERzBFAiEA4ylCl8qQDfNDfBw7VkxVN0bUs4N56TZDqZhAdEv01N8CIDtOG5VbmWNZeagC8VRfzEhu+ratFCo3fTu2liV8kH5h"

pkcs7/envelope_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestEncrypt(t *testing.T) {
9898
if err != nil {
9999
t.Fatalf("cannot Parse encrypted result: %s", err)
100100
}
101-
result, err := p7.Decrypt(cert.Certificate, *cert.PrivateKey)
101+
result, err := p7.Decrypt(cert.Certificate, cert.PrivateKey)
102102
if err != nil {
103103
t.Fatalf("cannot Decrypt encrypted result: %s", err)
104104
}
@@ -133,7 +133,7 @@ func TestEncryptSM(t *testing.T) {
133133
if err != nil {
134134
t.Fatalf("cannot Parse encrypted result: %s", err)
135135
}
136-
result, err := p7.Decrypt(cert.Certificate, *cert.PrivateKey)
136+
result, err := p7.Decrypt(cert.Certificate, cert.PrivateKey)
137137
if err != nil {
138138
t.Fatalf("cannot Decrypt encrypted result: %s", err)
139139
}
@@ -169,7 +169,7 @@ func TestEncryptCFCA(t *testing.T) {
169169
if err != nil {
170170
t.Fatalf("cannot Parse encrypted result: %s", err)
171171
}
172-
result, err := p7.DecryptCFCA(cert.Certificate, *cert.PrivateKey)
172+
result, err := p7.DecryptCFCA(cert.Certificate, cert.PrivateKey)
173173
if err != nil {
174174
t.Fatalf("cannot Decrypt encrypted result: %s", err)
175175
}
@@ -289,7 +289,7 @@ func TestEnvelopeMessageCFCA(t *testing.T) {
289289
if err != nil {
290290
t.Fatalf("cannot Parse encrypted result: %s", err)
291291
}
292-
result, err := p7.Decrypt(cert.Certificate, *cert.PrivateKey)
292+
result, err := p7.Decrypt(cert.Certificate, cert.PrivateKey)
293293
if err != nil {
294294
t.Fatalf("cannot Decrypt encrypted result: %s", err)
295295
}

pkcs7/pkcs7_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func fromBase10(base10 string) *big.Int {
8383

8484
type certKeyPair struct {
8585
Certificate *smx509.Certificate
86-
PrivateKey *crypto.PrivateKey
86+
PrivateKey crypto.PrivateKey
8787
}
8888

8989
func createTestCertificate(sigAlg x509.SignatureAlgorithm, allCA bool) (certKeyPair, error) {
@@ -125,7 +125,7 @@ func createTestCertificateByIssuer(name string, issuer *certKeyPair, sigAlg x509
125125
}
126126
if issuer != nil {
127127
issuerCert = issuer.Certificate
128-
issuerKey = *issuer.PrivateKey
128+
issuerKey = issuer.PrivateKey
129129
}
130130

131131
switch sigAlg {

pkcs7/sign.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ func (sd *SignedData) AddSigner(ee *smx509.Certificate, pkey crypto.PrivateKey,
143143
// The signature algorithm used to hash the data is the one of the end-entity
144144
// certificate.
145145
func (sd *SignedData) AddSignerChain(ee *smx509.Certificate, pkey crypto.PrivateKey, parents []*smx509.Certificate, config SignerInfoConfig) error {
146+
if ee == nil {
147+
return errors.New("pkcs7: certificate is nil")
148+
}
149+
146150
// Following RFC 2315, 9.2 SignerInfo type, the distinguished name of
147151
// the issuer of the end-entity signer is stored in the issuerAndSerialNumber
148152
// section of the SignedData.SignerInfo, alongside the serial number of

pkcs7/sign_enveloped_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func TestCreateSignedEvnvelopedDataSM(t *testing.T) {
171171
t.Fatal(err)
172172
}
173173
privKey := make([]byte, 32)
174-
sm2Key, ok := (*encryptKey.PrivateKey).(*sm2.PrivateKey)
174+
sm2Key, ok := (encryptKey.PrivateKey).(*sm2.PrivateKey)
175175
if !ok {
176176
t.Fatal("should be sm2 private key")
177177
}
@@ -183,7 +183,7 @@ func TestCreateSignedEvnvelopedDataSM(t *testing.T) {
183183
if err != nil {
184184
t.Fatal(err)
185185
}
186-
err = saed.AddSigner(rootCert.Certificate, *rootCert.PrivateKey)
186+
err = saed.AddSigner(rootCert.Certificate, rootCert.PrivateKey)
187187
if err != nil {
188188
t.Fatal(err)
189189
}
@@ -203,7 +203,7 @@ func TestCreateSignedEvnvelopedDataSM(t *testing.T) {
203203
if err != nil {
204204
t.Fatal(err)
205205
}
206-
encKeyBytes, err := p7Data.DecryptAndVerify(recipient.Certificate, *recipient.PrivateKey, func() error {
206+
encKeyBytes, err := p7Data.DecryptAndVerify(recipient.Certificate, recipient.PrivateKey, func() error {
207207
return p7Data.Verify()
208208
})
209209
if err != nil {
@@ -234,7 +234,7 @@ func TestCreateSignedEvnvelopedData(t *testing.T) {
234234
t.Fatal(err)
235235
}
236236
privKey := make([]byte, 32)
237-
ecdsaKey, ok := (*encryptKey.PrivateKey).(*ecdsa.PrivateKey)
237+
ecdsaKey, ok := (encryptKey.PrivateKey).(*ecdsa.PrivateKey)
238238
if !ok {
239239
t.Fatal("should be ecdsa private key")
240240
}
@@ -247,7 +247,7 @@ func TestCreateSignedEvnvelopedData(t *testing.T) {
247247
t.Fatal(err)
248248
}
249249
saed.SetDigestAlgorithm(OIDDigestAlgorithmSHA256)
250-
err = saed.AddSigner(rootCert.Certificate, *rootCert.PrivateKey)
250+
err = saed.AddSigner(rootCert.Certificate, rootCert.PrivateKey)
251251
if err != nil {
252252
t.Fatal(err)
253253
}
@@ -288,7 +288,7 @@ func TestCreateSignedEvnvelopedData(t *testing.T) {
288288
t.Errorf("Recipient issuer name does not match.\n\tExpected:%x\n\tActual:%x", recipient.Certificate.RawIssuer, recipients[0].RawIssuer)
289289
}
290290

291-
encKeyBytes, err := p7Data.DecryptAndVerify(recipient.Certificate, *recipient.PrivateKey, func() error {
291+
encKeyBytes, err := p7Data.DecryptAndVerify(recipient.Certificate, recipient.PrivateKey, func() error {
292292
return p7Data.Verify()
293293
})
294294
if err != nil {

pkcs7/sign_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func testSign(t *testing.T, isSM bool, content []byte, sigalgs []x509.SignatureA
5151
signerDigest, _ := getDigestOIDForSignatureAlgorithm(sigalgsigner)
5252
toBeSigned.SetDigestAlgorithm(signerDigest)
5353

54-
if err := toBeSigned.AddSignerChain(signerCert.Certificate, *signerCert.PrivateKey, parents, SignerInfoConfig{}); err != nil {
54+
if err := toBeSigned.AddSignerChain(signerCert.Certificate, signerCert.PrivateKey, parents, SignerInfoConfig{}); err != nil {
5555
t.Fatalf("test %s/%s/%s: cannot add signer: %s", sigalgroot, sigalginter, sigalgsigner, err)
5656
}
5757
if testDetach {
@@ -152,7 +152,7 @@ func TestUnmarshalSignedAttribute(t *testing.T) {
152152
}
153153
oidTest := asn1.ObjectIdentifier{2, 3, 4, 5, 6, 7}
154154
testValue := "TestValue"
155-
if err := toBeSigned.AddSigner(cert.Certificate, *cert.PrivateKey, SignerInfoConfig{
155+
if err := toBeSigned.AddSigner(cert.Certificate, cert.PrivateKey, SignerInfoConfig{
156156
ExtraSignedAttributes: []Attribute{{Type: oidTest, Value: testValue}},
157157
}); err != nil {
158158
t.Fatalf("Cannot add signer: %s", err)
@@ -190,7 +190,7 @@ func TestSkipCertificates(t *testing.T) {
190190
t.Fatalf("Cannot initialize signed data: %s", err)
191191
}
192192

193-
if err := toBeSigned.AddSigner(cert.Certificate, *cert.PrivateKey, SignerInfoConfig{}); err != nil {
193+
if err := toBeSigned.AddSigner(cert.Certificate, cert.PrivateKey, SignerInfoConfig{}); err != nil {
194194
t.Fatalf("Cannot add signer: %s", err)
195195
}
196196
signed, err := toBeSigned.Finish()
@@ -209,7 +209,7 @@ func TestSkipCertificates(t *testing.T) {
209209
if err != nil {
210210
t.Fatalf("Cannot initialize signed data: %s", err)
211211
}
212-
if err := toBeSigned2.AddSigner(cert.Certificate, *cert.PrivateKey, SignerInfoConfig{SkipCertificates: true}); err != nil {
212+
if err := toBeSigned2.AddSigner(cert.Certificate, cert.PrivateKey, SignerInfoConfig{SkipCertificates: true}); err != nil {
213213
t.Fatalf("Cannot add signer: %s", err)
214214
}
215215
signed, err = toBeSigned2.Finish()
@@ -313,7 +313,7 @@ func TestSignWithoutAttr(t *testing.T) {
313313
if err != nil {
314314
t.Fatalf("Cannot initialize signed data: %s", err)
315315
}
316-
if err := toBeSigned.SignWithoutAttr(cert.Certificate, *cert.PrivateKey, SignerInfoConfig{SkipCertificates: sigalg.skipCert}); err != nil {
316+
if err := toBeSigned.SignWithoutAttr(cert.Certificate, cert.PrivateKey, SignerInfoConfig{SkipCertificates: sigalg.skipCert}); err != nil {
317317
t.Fatalf("Cannot add signer: %s", err)
318318
}
319319
signed, err := toBeSigned.Finish()

pkcs7/verify_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ but that's not what ships are built for.
527527
t.Fatal(err)
528528
}
529529
var derKey []byte
530-
priv := *signerCert.PrivateKey
530+
priv := signerCert.PrivateKey
531531
switch priv := priv.(type) {
532532
case *rsa.PrivateKey:
533533
derKey = x509.MarshalPKCS1PrivateKey(priv)

0 commit comments

Comments
 (0)