| 1 |
Subject: [PATCH 1/5] Update tests to match current exception strings for malformed certs. |
| 2 |
From: David Eger <[email protected]> |
| 3 |
|
| 4 |
Date: Fri, 3 Sep 2021 14:04:31 -0700 |
| 5 |
|
| 6 |
|
| 7 |
--- |
| 8 |
crypto/pemutil/pem_test.go | 4 ++-- |
| 9 |
crypto/x509util/identity_test.go | 2 +- |
| 10 |
2 files changed, 3 insertions(+), 3 deletions(-) |
| 11 |
|
| 12 |
diff --git a/crypto/pemutil/pem_test.go b/crypto/pemutil/pem_test.go |
| 13 |
index 30851dcc..3c4249e2 100644 |
| 14 |
--- a/crypto/pemutil/pem_test.go |
| 15 |
+++ b/crypto/pemutil/pem_test.go |
| 16 |
@@ -230,7 +230,7 @@ func TestReadCertificate(t *testing.T) { |
| 17 |
{"testdata/notexists.crt", errors.New("open testdata/notexists.crt failed: no such file or directory")}, |
| 18 |
{"testdata/badca.crt", errors.New("error parsing testdata/badca.crt")}, |
| 19 |
{"testdata/badpem.crt", errors.New("error decoding testdata/badpem.crt: not a valid PEM encoded block")}, |
| 20 |
|
| 21 |
+ {"testdata/badder.crt", errors.New("error parsing testdata/badder.crt: x509:")}, |
| 22 |
{"testdata/openssl.p256.pem", errors.New("error decoding PEM: file 'testdata/openssl.p256.pem' does not contain a certificate")}, |
| 23 |
} |
| 24 |
|
| 25 |
@@ -259,7 +259,7 @@ func TestReadCertificateBundle(t *testing.T) { |
| 26 |
{"testdata/notexists.crt", 0, errors.New("open testdata/notexists.crt failed: no such file or directory")}, |
| 27 |
{"testdata/badca.crt", 0, errors.New("error parsing testdata/badca.crt")}, |
| 28 |
{"testdata/badpem.crt", 0, errors.New("error decoding PEM: file 'testdata/badpem.crt' contains unexpected data")}, |
| 29 |
|
| 30 |
+ {"testdata/badder.crt", 0, errors.New("error parsing testdata/badder.crt: x509:")}, |
| 31 |
{"testdata/openssl.p256.pem", 0, errors.New("error decoding PEM: file 'testdata/openssl.p256.pem' is not a certificate bundle")}, |
| 32 |
} |
| 33 |
|
| 34 |
diff --git a/crypto/x509util/identity_test.go b/crypto/x509util/identity_test.go |
| 35 |
index 06020356..4e9ba728 100644 |
| 36 |
--- a/crypto/x509util/identity_test.go |
| 37 |
+++ b/crypto/x509util/identity_test.go |
| 38 |
@@ -26,7 +26,7 @@ func TestLoadIdentityFromDisk(t *testing.T) { |
| 39 |
crtPath: testBadCert, |
| 40 |
keyPath: "", |
| 41 |
pass: "", |
| 42 |
|
| 43 |
+ err: errors.Errorf("error parsing %s: x509: trailing data", |
| 44 |
testBadCert), |
| 45 |
}, |
| 46 |
"error parsing rsa key": { |
| 47 |
|
| 48 |
From 04a4ce7aaffbdca562e6da7c0227b4004223ac96 Mon Sep 17 00:00:00 2001 |
| 49 |
From: davideger <[email protected]> |
| 50 |
Date: Fri, 3 Sep 2021 15:02:00 -0700 |
| 51 |
Subject: [PATCH 2/5] Update crypto/pemutil/pem_test.go |
| 52 |
|
| 53 |
Co-authored-by: Mariano Cano <[email protected]> |
| 54 |
--- |
| 55 |
crypto/pemutil/pem_test.go | 2 +- |
| 56 |
1 file changed, 1 insertion(+), 1 deletion(-) |
| 57 |
|
| 58 |
diff --git a/crypto/pemutil/pem_test.go b/crypto/pemutil/pem_test.go |
| 59 |
index 3c4249e2..667147cb 100644 |
| 60 |
--- a/crypto/pemutil/pem_test.go |
| 61 |
+++ b/crypto/pemutil/pem_test.go |
| 62 |
@@ -230,7 +230,7 @@ func TestReadCertificate(t *testing.T) { |
| 63 |
{"testdata/notexists.crt", errors.New("open testdata/notexists.crt failed: no such file or directory")}, |
| 64 |
{"testdata/badca.crt", errors.New("error parsing testdata/badca.crt")}, |
| 65 |
{"testdata/badpem.crt", errors.New("error decoding testdata/badpem.crt: not a valid PEM encoded block")}, |
| 66 |
|
| 67 |
+ {"testdata/badder.crt", errors.New("error parsing testdata/badder.crt:")}, |
| 68 |
{"testdata/openssl.p256.pem", errors.New("error decoding PEM: file 'testdata/openssl.p256.pem' does not contain a certificate")}, |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
From 638897281d10d8bf511dac813b509805e643c574 Mon Sep 17 00:00:00 2001 |
| 73 |
From: davideger <[email protected]> |
| 74 |
Date: Fri, 3 Sep 2021 15:02:07 -0700 |
| 75 |
Subject: [PATCH 3/5] Update crypto/x509util/identity_test.go |
| 76 |
|
| 77 |
Co-authored-by: Mariano Cano <[email protected]> |
| 78 |
--- |
| 79 |
crypto/x509util/identity_test.go | 2 +- |
| 80 |
1 file changed, 1 insertion(+), 1 deletion(-) |
| 81 |
|
| 82 |
diff --git a/crypto/x509util/identity_test.go b/crypto/x509util/identity_test.go |
| 83 |
index 4e9ba728..1b411ea2 100644 |
| 84 |
--- a/crypto/x509util/identity_test.go |
| 85 |
+++ b/crypto/x509util/identity_test.go |
| 86 |
@@ -26,7 +26,7 @@ func TestLoadIdentityFromDisk(t *testing.T) { |
| 87 |
crtPath: testBadCert, |
| 88 |
keyPath: "", |
| 89 |
pass: "", |
| 90 |
|
| 91 |
+ err: errors.Errorf("error parsing %s:", |
| 92 |
testBadCert), |
| 93 |
}, |
| 94 |
"error parsing rsa key": { |
| 95 |
|
| 96 |
From 8ea2d13f33eb6660060332860dcb9483b9ee5b1f Mon Sep 17 00:00:00 2001 |
| 97 |
From: davideger <[email protected]> |
| 98 |
Date: Fri, 3 Sep 2021 15:02:27 -0700 |
| 99 |
Subject: [PATCH 4/5] Update crypto/pemutil/pem_test.go |
| 100 |
|
| 101 |
Co-authored-by: Mariano Cano <[email protected]> |
| 102 |
--- |
| 103 |
crypto/pemutil/pem_test.go | 2 +- |
| 104 |
1 file changed, 1 insertion(+), 1 deletion(-) |
| 105 |
|
| 106 |
diff --git a/crypto/pemutil/pem_test.go b/crypto/pemutil/pem_test.go |
| 107 |
index 667147cb..b877e5c7 100644 |
| 108 |
--- a/crypto/pemutil/pem_test.go |
| 109 |
+++ b/crypto/pemutil/pem_test.go |
| 110 |
@@ -259,7 +259,7 @@ func TestReadCertificateBundle(t *testing.T) { |
| 111 |
{"testdata/notexists.crt", 0, errors.New("open testdata/notexists.crt failed: no such file or directory")}, |
| 112 |
{"testdata/badca.crt", 0, errors.New("error parsing testdata/badca.crt")}, |
| 113 |
{"testdata/badpem.crt", 0, errors.New("error decoding PEM: file 'testdata/badpem.crt' contains unexpected data")}, |
| 114 |
|
| 115 |
+ {"testdata/badder.crt", 0, errors.New("error parsing testdata/badder.crt::")}, |
| 116 |
{"testdata/openssl.p256.pem", 0, errors.New("error decoding PEM: file 'testdata/openssl.p256.pem' is not a certificate bundle")}, |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
From 024e266c29686ed96542251c9ee1920f9f53be15 Mon Sep 17 00:00:00 2001 |
| 121 |
From: Mariano Cano <[email protected]> |
| 122 |
Date: Fri, 3 Sep 2021 15:06:09 -0700 |
| 123 |
Subject: [PATCH 5/5] Remove extra colon |
| 124 |
|
| 125 |
--- |
| 126 |
crypto/pemutil/pem_test.go | 2 +- |
| 127 |
1 file changed, 1 insertion(+), 1 deletion(-) |
| 128 |
|
| 129 |
diff --git a/crypto/pemutil/pem_test.go b/crypto/pemutil/pem_test.go |
| 130 |
index b877e5c7..45c91a02 100644 |
| 131 |
--- a/crypto/pemutil/pem_test.go |
| 132 |
+++ b/crypto/pemutil/pem_test.go |
| 133 |
@@ -259,7 +259,7 @@ func TestReadCertificateBundle(t *testing.T) { |
| 134 |
{"testdata/notexists.crt", 0, errors.New("open testdata/notexists.crt failed: no such file or directory")}, |
| 135 |
{"testdata/badca.crt", 0, errors.New("error parsing testdata/badca.crt")}, |
| 136 |
{"testdata/badpem.crt", 0, errors.New("error decoding PEM: file 'testdata/badpem.crt' contains unexpected data")}, |
| 137 |
|
| 138 |
+ {"testdata/badder.crt", 0, errors.New("error parsing testdata/badder.crt:")}, |
| 139 |
{"testdata/openssl.p256.pem", 0, errors.New("error decoding PEM: file 'testdata/openssl.p256.pem' is not a certificate bundle")}, |
| 140 |
} |
| 141 |
|