File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 14
14
import base64
15
15
import re
16
16
import sys
17
+ import string
17
18
18
19
from ._errors import unwrap
19
20
from ._types import type_name as _type_name , str_cls , byte_cls
@@ -144,14 +145,19 @@ def _unarmor(pem_bytes):
144
145
found_start = False
145
146
found_end = False
146
147
148
+ # RFC 7468#page-5
149
+ label_chars = '[!-,.-~]' # 0x21-0x2C, 0x2E-0x7E
150
+ label_re = rf'''^(?:---- |-----)BEGIN ({ label_chars } (([- ]?{ label_chars } )*))?(?: ----|-----)''' .encode ('ascii' )
151
+
147
152
for line in pem_bytes .splitlines (False ):
148
153
if line == b'' :
149
154
continue
150
155
151
156
if state == "trash" :
152
157
# Look for a starting line since some CA cert bundle show the cert
153
- # into in a parsed format above each PEM block
154
- type_name_match = re .match (b'^(?:---- |-----)BEGIN ([A-Z0-9 ]+)(?: ----|-----)' , line )
158
+ # info in a parsed format above each PEM block
159
+
160
+ type_name_match = re .match (label_re , line )
155
161
if not type_name_match :
156
162
continue
157
163
object_type = type_name_match .group (1 ).decode ('ascii' )
You can’t perform that action at this time.
0 commit comments