Skip to content
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

Add support to encrypt with an RSA public key #379

Merged
merged 2 commits into from
May 10, 2024

Conversation

cmd-ntrf
Copy link
Contributor

@cmd-ntrf cmd-ntrf commented May 6, 2024

Based on the header of the public key, we can identify if we have a X509 certificate or an RSA public key. If we have an RSA public key, we simply generate a X509 certificate on the fly that will contain only the information required by encrypt.

Based on the header of the public key, we can identify if we have
a X509 certificate or an RSA public key. If we have an RSA public
key, we simply generate a X509 certificate on the fly that will
contain only the information required by encrypt.
public_key_rsa = OpenSSL::PKey::RSA.new(public_key_pem)
public_key_x509 = OpenSSL::X509::Certificate.new
public_key_x509.public_key = public_key_rsa.public_key
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If neither branch of the if statement matches, does this raise an error that informs the user which types of content need to be in the .pem file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added an else clause to raise an exception to inform the user the key format is invalid to encrypt.

@cmd-ntrf cmd-ntrf requested a review from Sharpie May 8, 2024 13:03
@bastelfreak bastelfreak merged commit 1a4a85d into voxpupuli:master May 10, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants