Skip to content

Constify X509* usage where needed and use ASN1_STRING accessors#5239

Merged
matejk merged 2 commits intopocoproject:mainfrom
seektechnz:main
Mar 11, 2026
Merged

Constify X509* usage where needed and use ASN1_STRING accessors#5239
matejk merged 2 commits intopocoproject:mainfrom
seektechnz:main

Conversation

@seektechnz
Copy link
Contributor

Fixes: #5237

OpenSSL is moving most X509 pointers to const, this makes handlers compatible with const pointers. OpenSSL has also begun removing direct access to ASN1_STRING members, so we use the accessor functions instead of direct struct members.

@matejk
Copy link
Contributor

matejk commented Mar 10, 2026

Nice, clean PR — the changes are correct, minimal, and backward-compatible with OpenSSL >= 1.1.0.

One suggestion: in validFrom() and expiresOn(), the std::string is constructed from ASN1_STRING_get0_data() relying on null-termination:

std::string dateTime(reinterpret_cast<const char*>(ASN1_STRING_get0_data(certTime)));

It would be more robust to use the length accessor as well:

std::string dateTime(reinterpret_cast<const char*>(ASN1_STRING_get0_data(certTime)), ASN1_STRING_length(certTime));

This is a pre-existing issue (the old code did the same with certTime->data), so not a blocker for this PR, but worth considering as part of this change since you're already touching these lines.

@seektechnz
Copy link
Contributor Author

seektechnz commented Mar 10, 2026

That should be fixed now for safety. Thanks for looking it over!

@matejk matejk merged commit 413d2b9 into pocoproject:main Mar 11, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenSSL constifying interfaces and removing direct access from ASN1_STRING types

2 participants