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

OpenSSL to Java #250

Closed
snyff opened this issue Mar 16, 2022 · 1 comment
Closed

OpenSSL to Java #250

snyff opened this issue Mar 16, 2022 · 1 comment

Comments

@snyff
Copy link

snyff commented Mar 16, 2022

Hi team,

Following a discussion on twitter: https://twitter.com/headius/status/1503895505335726083

It would be great to be able to do:

key = OpenSSL::PKey::RSA.new(key).to_java(java.security.PrivateKey)
cert = OpenSSL::X509::Certificate.new(cert).to_java(javax.security.cert.X509Certificate)

instead of (similar-ish code):

private_key = Java::java.nio.file.Files.readAllBytes(Java::java.io.File.new("private.der").toPath());
keyFactory = Java::java.security.KeyFactory.getInstance("RSA");
keySpec = Java::java.security.spec.PKCS8EncodedKeySpec.new(private_key);
jprivate_key = keyFactory.generatePrivate(keySpec);
certificate = Java::java.nio.file.Files.readAllBytes(Java::java.io.File.new("cert.pem").toPath());
jcertificate = Java::javax.security.cert.X509Certificate.getInstance(certificate)
@kares
Copy link
Member

kares commented Apr 12, 2022

Thanks, the Pkey is relatively simple so I've added it d9dc3f0
The OpenSSL::X509::Certificate type already supports the to_java protocol and returns a javax.security.cert.X509Certificate by default, I wonder if you have a failure for that that you're seeing?

@kares kares closed this as completed Apr 13, 2022
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

No branches or pull requests

2 participants