forked from Lukasa/mkcert
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
241 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
// Copyright 2022 Cory Benfield | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package certs | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestDecodeDistrustAfterCert(t *testing.T) { | ||
testStr := `This Source Code | ||
BEGINDATA | ||
CKA_CLASS CK_OBJECT_CLASS CKO_NSS_BUILTIN_ROOT_LIST | ||
CKA_TOKEN CK_BBOOL CK_TRUE | ||
CKA_PRIVATE CK_BBOOL CK_FALSE | ||
CKA_MODIFIABLE CK_BBOOL CK_FALSE | ||
CKA_LABEL UTF8 "Mozilla Builtin Roots" | ||
# | ||
# Certificate "EC-ACC" | ||
# | ||
# Issuer: CN=EC-ACC,OU=Jerarquia Entitats de Certificacio Catalanes,OU=Vegeu https://www.catcert.net/verarrel (c)03,OU=Serveis Publics de Certificacio,O=Agencia Catalana de Certificacio (NIF Q-0801176-I),C=ES | ||
# Serial Number:ee:2b:3d:eb:d4:21:de:14:a8:62:ac:04:f3:dd:c4:01 | ||
# Subject: CN=EC-ACC,OU=Jerarquia Entitats de Certificacio Catalanes,OU=Vegeu https://www.catcert.net/verarrel (c)03,OU=Serveis Publics de Certificacio,O=Agencia Catalana de Certificacio (NIF Q-0801176-I),C=ES | ||
# Not Valid Before: Tue Jan 07 23:00:00 2003 | ||
# Not Valid After : Tue Jan 07 22:59:59 2031 | ||
# Fingerprint (SHA-256): 88:49:7F:01:60:2F:31:54:24:6A:E2:8C:4D:5A:EF:10:F1:D8:7E:BB:76:62:6F:4A:E0:B7:F9:5B:A7:96:87:99 | ||
# Fingerprint (SHA1): 28:90:3A:63:5B:52:80:FA:E6:77:4C:0B:6D:A7:D6:BA:A6:4A:F2:E8 | ||
CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE | ||
CKA_TOKEN CK_BBOOL CK_TRUE | ||
CKA_PRIVATE CK_BBOOL CK_FALSE | ||
CKA_MODIFIABLE CK_BBOOL CK_FALSE | ||
CKA_LABEL UTF8 "EC-ACC" | ||
CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 | ||
CKA_SUBJECT MULTILINE_OCTAL | ||
\060\201\363\061\013\060\011\006\003\125\004\006\023\002\105\123 | ||
\061\073\060\071\006\003\125\004\012\023\062\101\147\145\156\143 | ||
\151\141\040\103\141\164\141\154\141\156\141\040\144\145\040\103 | ||
\145\162\164\151\146\151\143\141\143\151\157\040\050\116\111\106 | ||
\040\121\055\060\070\060\061\061\067\066\055\111\051\061\050\060 | ||
\046\006\003\125\004\013\023\037\123\145\162\166\145\151\163\040 | ||
\120\165\142\154\151\143\163\040\144\145\040\103\145\162\164\151 | ||
\146\151\143\141\143\151\157\061\065\060\063\006\003\125\004\013 | ||
\023\054\126\145\147\145\165\040\150\164\164\160\163\072\057\057 | ||
\167\167\167\056\143\141\164\143\145\162\164\056\156\145\164\057 | ||
\166\145\162\141\162\162\145\154\040\050\143\051\060\063\061\065 | ||
\060\063\006\003\125\004\013\023\054\112\145\162\141\162\161\165 | ||
\151\141\040\105\156\164\151\164\141\164\163\040\144\145\040\103 | ||
\145\162\164\151\146\151\143\141\143\151\157\040\103\141\164\141 | ||
\154\141\156\145\163\061\017\060\015\006\003\125\004\003\023\006 | ||
\105\103\055\101\103\103 | ||
END | ||
CKA_ID UTF8 "0" | ||
CKA_ISSUER MULTILINE_OCTAL | ||
\060\201\363\061\013\060\011\006\003\125\004\006\023\002\105\123 | ||
\061\073\060\071\006\003\125\004\012\023\062\101\147\145\156\143 | ||
\151\141\040\103\141\164\141\154\141\156\141\040\144\145\040\103 | ||
\145\162\164\151\146\151\143\141\143\151\157\040\050\116\111\106 | ||
\040\121\055\060\070\060\061\061\067\066\055\111\051\061\050\060 | ||
\046\006\003\125\004\013\023\037\123\145\162\166\145\151\163\040 | ||
\120\165\142\154\151\143\163\040\144\145\040\103\145\162\164\151 | ||
\146\151\143\141\143\151\157\061\065\060\063\006\003\125\004\013 | ||
\023\054\126\145\147\145\165\040\150\164\164\160\163\072\057\057 | ||
\167\167\167\056\143\141\164\143\145\162\164\056\156\145\164\057 | ||
\166\145\162\141\162\162\145\154\040\050\143\051\060\063\061\065 | ||
\060\063\006\003\125\004\013\023\054\112\145\162\141\162\161\165 | ||
\151\141\040\105\156\164\151\164\141\164\163\040\144\145\040\103 | ||
\145\162\164\151\146\151\143\141\143\151\157\040\103\141\164\141 | ||
\154\141\156\145\163\061\017\060\015\006\003\125\004\003\023\006 | ||
\105\103\055\101\103\103 | ||
END | ||
CKA_SERIAL_NUMBER MULTILINE_OCTAL | ||
\002\020\356\053\075\353\324\041\336\024\250\142\254\004\363\335 | ||
\304\001 | ||
END | ||
CKA_VALUE MULTILINE_OCTAL | ||
\060\202\005\126\060\202\004\076\240\003\002\001\002\002\020\356 | ||
\053\075\353\324\041\336\024\250\142\254\004\363\335\304\001\060 | ||
\015\006\011\052\206\110\206\367\015\001\001\005\005\000\060\201 | ||
\363\061\013\060\011\006\003\125\004\006\023\002\105\123\061\073 | ||
\060\071\006\003\125\004\012\023\062\101\147\145\156\143\151\141 | ||
\040\103\141\164\141\154\141\156\141\040\144\145\040\103\145\162 | ||
\164\151\146\151\143\141\143\151\157\040\050\116\111\106\040\121 | ||
\055\060\070\060\061\061\067\066\055\111\051\061\050\060\046\006 | ||
\003\125\004\013\023\037\123\145\162\166\145\151\163\040\120\165 | ||
\142\154\151\143\163\040\144\145\040\103\145\162\164\151\146\151 | ||
\143\141\143\151\157\061\065\060\063\006\003\125\004\013\023\054 | ||
\126\145\147\145\165\040\150\164\164\160\163\072\057\057\167\167 | ||
\167\056\143\141\164\143\145\162\164\056\156\145\164\057\166\145 | ||
\162\141\162\162\145\154\040\050\143\051\060\063\061\065\060\063 | ||
\006\003\125\004\013\023\054\112\145\162\141\162\161\165\151\141 | ||
\040\105\156\164\151\164\141\164\163\040\144\145\040\103\145\162 | ||
\164\151\146\151\143\141\143\151\157\040\103\141\164\141\154\141 | ||
\156\145\163\061\017\060\015\006\003\125\004\003\023\006\105\103 | ||
\055\101\103\103\060\036\027\015\060\063\060\061\060\067\062\063 | ||
\060\060\060\060\132\027\015\063\061\060\061\060\067\062\062\065 | ||
\071\065\071\132\060\201\363\061\013\060\011\006\003\125\004\006 | ||
\023\002\105\123\061\073\060\071\006\003\125\004\012\023\062\101 | ||
\147\145\156\143\151\141\040\103\141\164\141\154\141\156\141\040 | ||
\144\145\040\103\145\162\164\151\146\151\143\141\143\151\157\040 | ||
\050\116\111\106\040\121\055\060\070\060\061\061\067\066\055\111 | ||
\051\061\050\060\046\006\003\125\004\013\023\037\123\145\162\166 | ||
\145\151\163\040\120\165\142\154\151\143\163\040\144\145\040\103 | ||
\145\162\164\151\146\151\143\141\143\151\157\061\065\060\063\006 | ||
\003\125\004\013\023\054\126\145\147\145\165\040\150\164\164\160 | ||
\163\072\057\057\167\167\167\056\143\141\164\143\145\162\164\056 | ||
\156\145\164\057\166\145\162\141\162\162\145\154\040\050\143\051 | ||
\060\063\061\065\060\063\006\003\125\004\013\023\054\112\145\162 | ||
\141\162\161\165\151\141\040\105\156\164\151\164\141\164\163\040 | ||
\144\145\040\103\145\162\164\151\146\151\143\141\143\151\157\040 | ||
\103\141\164\141\154\141\156\145\163\061\017\060\015\006\003\125 | ||
\004\003\023\006\105\103\055\101\103\103\060\202\001\042\060\015 | ||
\006\011\052\206\110\206\367\015\001\001\001\005\000\003\202\001 | ||
\017\000\060\202\001\012\002\202\001\001\000\263\042\307\117\342 | ||
\227\102\225\210\107\203\100\366\035\027\363\203\163\044\036\121 | ||
\363\230\212\303\222\270\377\100\220\005\160\207\140\311\000\251 | ||
\265\224\145\031\042\025\027\302\103\154\146\104\232\015\004\076 | ||
\071\157\245\113\172\252\143\267\212\104\235\331\143\221\204\146 | ||
\340\050\017\272\102\343\156\216\367\024\047\223\151\356\221\016 | ||
\243\137\016\261\353\146\242\162\117\022\023\206\145\172\076\333 | ||
\117\007\364\247\011\140\332\072\102\231\307\262\177\263\026\225 | ||
\034\307\371\064\265\224\205\325\231\136\240\110\240\176\347\027 | ||
\145\270\242\165\270\036\363\345\102\175\257\355\363\212\110\144 | ||
\135\202\024\223\330\300\344\377\263\120\162\362\166\366\263\135 | ||
\102\120\171\320\224\076\153\014\000\276\330\153\016\116\052\354 | ||
\076\322\314\202\242\030\145\063\023\167\236\232\135\032\023\330 | ||
\303\333\075\310\227\172\356\160\355\247\346\174\333\161\317\055 | ||
\224\142\337\155\326\365\070\276\077\245\205\012\031\270\250\330 | ||
\011\165\102\160\304\352\357\313\016\310\064\250\022\042\230\014 | ||
\270\023\224\266\113\354\360\320\220\347\047\002\003\001\000\001 | ||
\243\201\343\060\201\340\060\035\006\003\125\035\021\004\026\060 | ||
\024\201\022\145\143\137\141\143\143\100\143\141\164\143\145\162 | ||
\164\056\156\145\164\060\017\006\003\125\035\023\001\001\377\004 | ||
\005\060\003\001\001\377\060\016\006\003\125\035\017\001\001\377 | ||
\004\004\003\002\001\006\060\035\006\003\125\035\016\004\026\004 | ||
\024\240\303\213\104\252\067\245\105\277\227\200\132\321\361\170 | ||
\242\233\351\135\215\060\177\006\003\125\035\040\004\170\060\166 | ||
\060\164\006\013\053\006\001\004\001\365\170\001\003\001\012\060 | ||
\145\060\054\006\010\053\006\001\005\005\007\002\001\026\040\150 | ||
\164\164\160\163\072\057\057\167\167\167\056\143\141\164\143\145 | ||
\162\164\056\156\145\164\057\166\145\162\141\162\162\145\154\060 | ||
\065\006\010\053\006\001\005\005\007\002\002\060\051\032\047\126 | ||
\145\147\145\165\040\150\164\164\160\163\072\057\057\167\167\167 | ||
\056\143\141\164\143\145\162\164\056\156\145\164\057\166\145\162 | ||
\141\162\162\145\154\040\060\015\006\011\052\206\110\206\367\015 | ||
\001\001\005\005\000\003\202\001\001\000\240\110\133\202\001\366 | ||
\115\110\270\071\125\065\234\200\172\123\231\325\132\377\261\161 | ||
\073\314\071\011\224\136\326\332\357\276\001\133\135\323\036\330 | ||
\375\175\117\315\240\101\340\064\223\277\313\342\206\234\067\222 | ||
\220\126\034\334\353\051\005\345\304\236\307\065\337\212\014\315 | ||
\305\041\103\351\252\210\345\065\300\031\102\143\132\002\136\244 | ||
\110\030\072\205\157\334\235\274\077\235\234\301\207\270\172\141 | ||
\010\351\167\013\177\160\253\172\335\331\227\054\144\036\205\277 | ||
\274\164\226\241\303\172\022\354\014\032\156\203\014\074\350\162 | ||
\106\237\373\110\325\136\227\346\261\241\370\344\357\106\045\224 | ||
\234\211\333\151\070\276\354\134\016\126\307\145\121\345\120\210 | ||
\210\277\102\325\053\075\345\371\272\236\056\263\312\364\163\222 | ||
\002\013\276\114\146\353\040\376\271\313\265\231\177\346\266\023 | ||
\372\312\113\115\331\356\123\106\006\073\306\116\255\223\132\201 | ||
\176\154\052\113\152\005\105\214\362\041\244\061\220\207\154\145 | ||
\234\235\245\140\225\072\122\177\365\321\253\010\156\363\356\133 | ||
\371\210\075\176\270\157\156\003\344\102 | ||
END | ||
CKA_NSS_MOZILLA_CA_POLICY CK_BBOOL CK_TRUE | ||
# For Server Distrust After: Sat Dec 28 00:00:00 2019 | ||
CKA_NSS_SERVER_DISTRUST_AFTER MULTILINE_OCTAL | ||
\061\071\061\062\062\070\060\060\060\060\060\060\132 | ||
END | ||
# For Email Distrust After: Wed Aug 31 00:00:00 2022 | ||
CKA_NSS_EMAIL_DISTRUST_AFTER MULTILINE_OCTAL | ||
\062\062\060\070\063\061\060\060\060\060\060\060\132 | ||
END | ||
# Trust for "EC-ACC" | ||
# Issuer: CN=EC-ACC,OU=Jerarquia Entitats de Certificacio Catalanes,OU=Vegeu https://www.catcert.net/verarrel (c)03,OU=Serveis Publics de Certificacio,O=Agencia Catalana de Certificacio (NIF Q-0801176-I),C=ES | ||
# Serial Number:ee:2b:3d:eb:d4:21:de:14:a8:62:ac:04:f3:dd:c4:01 | ||
# Subject: CN=EC-ACC,OU=Jerarquia Entitats de Certificacio Catalanes,OU=Vegeu https://www.catcert.net/verarrel (c)03,OU=Serveis Publics de Certificacio,O=Agencia Catalana de Certificacio (NIF Q-0801176-I),C=ES | ||
# Not Valid Before: Tue Jan 07 23:00:00 2003 | ||
# Not Valid After : Tue Jan 07 22:59:59 2031 | ||
# Fingerprint (SHA-256): 88:49:7F:01:60:2F:31:54:24:6A:E2:8C:4D:5A:EF:10:F1:D8:7E:BB:76:62:6F:4A:E0:B7:F9:5B:A7:96:87:99 | ||
# Fingerprint (SHA1): 28:90:3A:63:5B:52:80:FA:E6:77:4C:0B:6D:A7:D6:BA:A6:4A:F2:E8 | ||
CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST | ||
CKA_TOKEN CK_BBOOL CK_TRUE | ||
CKA_PRIVATE CK_BBOOL CK_FALSE | ||
CKA_MODIFIABLE CK_BBOOL CK_FALSE | ||
CKA_LABEL UTF8 "EC-ACC" | ||
CKA_CERT_SHA1_HASH MULTILINE_OCTAL | ||
\050\220\072\143\133\122\200\372\346\167\114\013\155\247\326\272 | ||
\246\112\362\350 | ||
END | ||
CKA_CERT_MD5_HASH MULTILINE_OCTAL | ||
\353\365\235\051\015\141\371\102\037\174\302\272\155\343\025\011 | ||
END | ||
CKA_ISSUER MULTILINE_OCTAL | ||
\060\201\363\061\013\060\011\006\003\125\004\006\023\002\105\123 | ||
\061\073\060\071\006\003\125\004\012\023\062\101\147\145\156\143 | ||
\151\141\040\103\141\164\141\154\141\156\141\040\144\145\040\103 | ||
\145\162\164\151\146\151\143\141\143\151\157\040\050\116\111\106 | ||
\040\121\055\060\070\060\061\061\067\066\055\111\051\061\050\060 | ||
\046\006\003\125\004\013\023\037\123\145\162\166\145\151\163\040 | ||
\120\165\142\154\151\143\163\040\144\145\040\103\145\162\164\151 | ||
\146\151\143\141\143\151\157\061\065\060\063\006\003\125\004\013 | ||
\023\054\126\145\147\145\165\040\150\164\164\160\163\072\057\057 | ||
\167\167\167\056\143\141\164\143\145\162\164\056\156\145\164\057 | ||
\166\145\162\141\162\162\145\154\040\050\143\051\060\063\061\065 | ||
\060\063\006\003\125\004\013\023\054\112\145\162\141\162\161\165 | ||
\151\141\040\105\156\164\151\164\141\164\163\040\144\145\040\103 | ||
\145\162\164\151\146\151\143\141\143\151\157\040\103\141\164\141 | ||
\154\141\156\145\163\061\017\060\015\006\003\125\004\003\023\006 | ||
\105\103\055\101\103\103 | ||
END | ||
CKA_SERIAL_NUMBER MULTILINE_OCTAL | ||
\002\020\356\053\075\353\324\041\336\024\250\142\254\004\363\335 | ||
\304\001 | ||
END | ||
CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR | ||
CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST | ||
CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST | ||
CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE | ||
` | ||
reader := strings.NewReader(testStr) | ||
_, _, objects := ParseInput(reader) | ||
certs := OutputTrustedCerts(objects) | ||
if len(certs) != 0 { | ||
t.Errorf("Unexpected cert count: %v", len(certs)) | ||
} | ||
|
||
} |