Commit e69b1e0
add caching for issuer and subject (#14442)
* x509/certificate: cache issuer getter result
Store the Python Name object in a PyOnceLock so that repeated accesses
avoid re-running parse_name, which allocates a full Python Name object
tree from ASN.1 on every call.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
* x509/certificate: cache subject getter result
Store the Python Name object in a PyOnceLock so that repeated accesses
avoid re-running parse_name, which allocates a full Python Name object
tree from ASN.1 on every call.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
* tests/x509: fix test_country_jurisdiction_country_too_long after subject caching
The test assumed cert.subject re-parses the Name on every call, so it
checked each too-long-country warning in its own pytest.warns block.
After subject caching, parse_name runs only once (on the first access)
and emits both COUNTRY_NAME and JURISDICTION_COUNTRY_NAME warnings in a
single call. Subsequent accesses return the cached Name object without
re-parsing, so the second block saw no warnings.
Merge both assertions into a single pytest.warns block, which correctly
captures all warnings emitted during the first (and only) parse.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
---------
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 1807083 commit e69b1e0
File tree
4 files changed
+30
-6
lines changed- src/rust/src
- x509
- tests/x509
4 files changed
+30
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
768 | 768 | | |
769 | 769 | | |
770 | 770 | | |
| 771 | + | |
| 772 | + | |
771 | 773 | | |
772 | 774 | | |
773 | 775 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
141 | | - | |
142 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
143 | 152 | | |
144 | 153 | | |
145 | 154 | | |
146 | 155 | | |
147 | | - | |
148 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
149 | 165 | | |
150 | 166 | | |
151 | 167 | | |
| |||
441 | 457 | | |
442 | 458 | | |
443 | 459 | | |
| 460 | + | |
| 461 | + | |
444 | 462 | | |
445 | 463 | | |
446 | 464 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| 268 | + | |
| 269 | + | |
268 | 270 | | |
269 | 271 | | |
270 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1028 | 1028 | | |
1029 | 1029 | | |
1030 | 1030 | | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
1031 | 1035 | | |
1032 | 1036 | | |
1033 | 1037 | | |
1034 | 1038 | | |
1035 | 1039 | | |
1036 | 1040 | | |
1037 | 1041 | | |
1038 | | - | |
1039 | | - | |
1040 | 1042 | | |
1041 | 1043 | | |
1042 | 1044 | | |
| |||
0 commit comments