mirror of
https://github.com/emmansun/gmsm.git
synced 2025-06-29 00:37:51 +08:00
pkcs7: test clean
This commit is contained in:
parent
a93f7fd94d
commit
c1289f7224
@ -8,7 +8,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
@ -151,7 +150,7 @@ func TestUnmarshalSignedAttribute(t *testing.T) {
|
|||||||
oidTest := asn1.ObjectIdentifier{2, 3, 4, 5, 6, 7}
|
oidTest := asn1.ObjectIdentifier{2, 3, 4, 5, 6, 7}
|
||||||
testValue := "TestValue"
|
testValue := "TestValue"
|
||||||
if err := toBeSigned.AddSigner(cert.Certificate, *cert.PrivateKey, SignerInfoConfig{
|
if err := toBeSigned.AddSigner(cert.Certificate, *cert.PrivateKey, SignerInfoConfig{
|
||||||
ExtraSignedAttributes: []Attribute{Attribute{Type: oidTest, Value: testValue}},
|
ExtraSignedAttributes: []Attribute{{Type: oidTest, Value: testValue}},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
t.Fatalf("Cannot add signer: %s", err)
|
t.Fatalf("Cannot add signer: %s", err)
|
||||||
}
|
}
|
||||||
@ -257,12 +256,4 @@ func testOpenSSLParse(t *testing.T, certBytes []byte) {
|
|||||||
if err := tmpCertFile.Close(); err != nil {
|
if err := tmpCertFile.Close(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
func fromHex(s string) *big.Int {
|
|
||||||
result, ok := new(big.Int).SetString(s, 16)
|
|
||||||
if !ok {
|
|
||||||
panic(s)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
@ -254,12 +254,16 @@ func TestVerifyFirefoxAddon(t *testing.T) {
|
|||||||
t.Errorf("Verify failed with error: %v", err)
|
t.Errorf("Verify failed with error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fake content
|
||||||
p7.Content = []byte("bad content")
|
p7.Content = []byte("bad content")
|
||||||
if err = p7.VerifyWithChain(certPool); err == nil {
|
if err = p7.VerifyWithChain(certPool); err == nil {
|
||||||
t.Errorf("Verify with incorrect content did not error")
|
t.Errorf("Verify with incorrect content did not error")
|
||||||
}
|
}
|
||||||
p7.Content = FirefoxAddonContent
|
p7.Content = FirefoxAddonContent
|
||||||
|
|
||||||
|
if p7.GetOnlySigner() == nil {
|
||||||
|
t.Errorf("no only signer")
|
||||||
|
}
|
||||||
// The chain has validity:
|
// The chain has validity:
|
||||||
//
|
//
|
||||||
// EE: 2016-08-17 20:04:58 +0000 UTC 2021-08-16 20:04:58 +0000 UTC
|
// EE: 2016-08-17 20:04:58 +0000 UTC 2021-08-16 20:04:58 +0000 UTC
|
||||||
|
Loading…
x
Reference in New Issue
Block a user