I need to use openssl in java code. e.g.
$ openssl genrsa -out private.pem 2048
$ openssl pkcs8 -topk8 -in private.pem -outform DER -out private.der -nocrypt
$ openssl rsa -in private.pem -pubout -outform DER -out public.der
Is there any library or method to implement this?
The best way is to use Java library for this actions. I can’t write exact code right now but it isn’t very hard. Look at java.security.KeyPairGenerator and so on. And it will be good experience in understanding of cryptography.
But if you need only to call this three command line, Process.waitFor() call is the answer. You can use this class.