-
-
Notifications
You must be signed in to change notification settings - Fork 902
split CSR, CRL and SPKAC out of X509 and implement lazy loading #2105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+11,823
−5,833
Conversation
This file contains hidden or 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
the goal is to make X509 easy to use and making the extension criticalness required when it can be either / or is not making things easier
Consider, for example:
$data = 'a' . base64_decode('MD6gJQYKKwYBBAGCNxQCA6AXDBVvZmZpY2VAY2VydGRpZ2l0YWwucm+BFW9mZmljZUBjZXJ0ZGlnaXRhbC5ybw==');
$x509 = X509::load($data);
print_r($x509);
A unit test is not being added because the exact verbiage of the message
is subject to change
it doesn't work super well and i'm not sure further work on it is necessarily the best use of my time
prior to this change an explicit critical value for an extension would return an instance of Boolean whereas an implicit critical value would return an primitive boolean. this change makes the behavior more consistent
setDN([]) already works but this change makes that more efficient
in the documentation i'm writing distinguished names have their own page. like there's enough to write about them such that duplicating that info on each of the pages for X509s, CSRs and CRLs is most unappealing. in light of that having a class agnostic way to reference the DN_* constants is appealing
…into x509-split
whereas validateSignature() traverses the certificate chain these methods don't. they're called by validateSignature() when traversing the certificate chain but don't, themselves, traverse it the fact that validateSignature() calls them kinda makes them redundant
This was referenced Nov 13, 2025
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR splits CSR, CRL and SPKAC out of X509 and into their own classes and implements lazy loading, which addresses #2073.
The documentation for this new API can be found here:
https://terrafrost.com/phpseclib/v4/docs/file/x509
When phpseclib 4.0 is released the documentation that currently lives at the above URL will be moved to phpseclib.com. Reason being that the above isn't just documenting features new to phpseclib 4.0 but also constitutes a complete site redesign and rebranding of phpseclib.
With phpseclib 3.0 one would read a certificate thusly:
With phpseclib 4.0 you would now read a certificate like so:
Creating new X509 certificates has also changed. Here's how you'd create a self-signed certificate with phpseclib 3.0:
Here's how you'd create a self-signed certificate with phpseclib 4.0:
One big difference is that private keys can now sign objects implementing the
\phpseclib3\File\Common\Signableinterface. When such an object is passed to thesign()method the methods that that object implements tell the PrivateKey object what bytes the signature should be created from and where the signature should be placed.https://terrafrost.com/phpseclib/v4/docs/file/x509#signing also discusses the use of PFX's to sign certificates. PFX support will be implemented by December 31 of this year at the latest.
The CRL, CSR and SPKAC objects all work similarly.
In-so-far as lazy loading is concerned... as discussed at https://terrafrost.com/phpseclib/v4/docs/file/detail-constructed#speed-and-memory-usage there are actually several different "modes" that phpseclib v4 supports. Here's a breakdown of the time and memory usage of each of those "modes" on a 2.2mb CRL with 40,000+ revoked serial numbers:
290mb vs 43mb is an improvement of almost 6.7x.
This work has been commissioned by the Sovereign Tech Fund: