Skip to content

Commit 4517585

Browse files
alexclaude
andauthored
Refactor ASN1_STRING access to use accessor functions (#1462)
Replace direct access to .data and .length attributes with ASN1_STRING_get0_data() and ASN1_STRING_length() accessor functions in the X509Extension._subjectAltNameString() method. This improves compatibility with OpenSSL's opaque structure design and follows the pattern used elsewhere in the codebase. Co-authored-by: Claude <[email protected]>
1 parent d7c41d3 commit 4517585

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/OpenSSL/crypto.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -885,9 +885,11 @@ def _subjectAltNameString(self) -> str:
885885
_lib.GENERAL_NAME_print(bio, name)
886886
parts.append(_bio_to_string(bio).decode("utf-8"))
887887
else:
888-
value = _ffi.buffer(name.d.ia5.data, name.d.ia5.length)[
889-
:
890-
].decode("utf-8")
888+
asn1_string = _ffi.cast("ASN1_STRING*", name.d.ia5)
889+
value = _ffi.buffer(
890+
_lib.ASN1_STRING_get0_data(asn1_string),
891+
_lib.ASN1_STRING_length(asn1_string),
892+
)[:].decode("utf-8")
891893
parts.append(label + ":" + value)
892894
return ", ".join(parts)
893895

0 commit comments

Comments
 (0)