Introduce OpenSslException for detailed error handling in OpenSSL operations#29
Merged
ievgeniiskliarenko merged 3 commits intomasterfrom Feb 2, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new OpenSslException class to improve error handling in OpenSSL operations by capturing detailed error information while preventing sensitive error details from being exposed externally through generic exception messages.
Changes:
- Added
OpenSslExceptionclass that collects and stores OpenSSL error strings - Updated
OpenSSLVerifyto useOpenSslExceptionas a previous exception when verification fails - Updated
OpenSSLSignto useOpenSslExceptionas a previous exception when signing fails
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| vicephp/Virtue-JWT/src/JWT/OpenSslException.php | Introduces new exception class for capturing OpenSSL error details with a static method to collect error strings |
| vicephp/Virtue-JWT/src/JWT/Algorithms/OpenSSLVerify.php | Refactors error handling to collect OpenSSL errors and pass them as previous exceptions instead of exposing them in messages |
| vicephp/Virtue-JWT/src/JWT/Algorithms/OpenSSLSign.php | Updates signing error handling to use OpenSslException as previous exception for better error context |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
evmoroz
reviewed
Jan 30, 2026
|
|
||
| if (!$private = \openssl_pkey_get_private($this->private->asPem(), $this->private->passphrase())) { | ||
| throw new SignFailed('Key or passphrase are invalid.'); | ||
| $opensslException = new OpenSslException(OpenSslException::collectErrors()); |
Contributor
There was a problem hiding this comment.
Perhaps collectErrors could return an exception. Otherwise the API is slightly clunky
Contributor
Author
There was a problem hiding this comment.
Good point, on it.
Contributor
Author
There was a problem hiding this comment.
Addressed
…prove error collection
evmoroz
approved these changes
Jan 30, 2026
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
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.
The idea is that we can return original OpenSSL errors to the caller, but we do not want to return them as a part of the
VerificationFailedmessage because in this way they will be dispatched to the outside, which might provide additional and sensitive information to the attacker.