How to use opensh private key in Java?

I am generating a DSA key using the following command:

ssh-keygen -t dsa

Then, I try to sign the data using the bouncycastle API, as follows:

    KeyFactory keyFactory = KeyFactory.getInstance("DSA");
    String privateKeyContent = // the content of the generated file

    //init privateKey
    byte[] pemContent = null;
    PEMParser pemParser = new PEMParser(new StringReader(privateKeyContent));
    Object pemObject = pemParser.readObject(); // throws

And get this exception

So I've been trying to use this example to convert the key file to PEM and execute:

ssh-keygen -e -f key -m PEM > key.pem

But I received an error:

do_convert_to_pem: unsupported key type DSA

Any ideas on how to solve this problem?

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>