File tree Expand file tree Collapse file tree 1 file changed +1
-9
lines changed
utils/src/main/java/com/cloud/utils/ssh Expand file tree Collapse file tree 1 file changed +1
-9
lines changed Original file line number Diff line number Diff line change 2020package com .cloud .utils .ssh ;
2121
2222import java .io .ByteArrayOutputStream ;
23- import java .io .StringWriter ;
2423import java .math .BigInteger ;
2524import java .nio .ByteBuffer ;
2625import java .nio .charset .StandardCharsets ;
3231
3332import org .apache .cloudstack .utils .security .CertUtils ;
3433import org .apache .commons .codec .binary .Base64 ;
35- import org .bouncycastle .util .io .pem .PemObject ;
36- import org .bouncycastle .util .io .pem .PemWriter ;
3734
3835public class SSHKeysHelper {
3936
@@ -149,12 +146,7 @@ public String getPrivateKey() {
149146 return null ;
150147 }
151148 try {
152- final PemObject pemObject = new PemObject ("RSA PRIVATE KEY" , keyPair .getPrivate ().getEncoded ());
153- final StringWriter sw = new StringWriter ();
154- try (final PemWriter pw = new PemWriter (sw )) {
155- pw .writeObject (pemObject );
156- }
157- return sw .toString ();
149+ return CertUtils .privateKeyToPem (keyPair .getPrivate ());
158150 } catch (Exception e ) {
159151 e .printStackTrace ();
160152 }
You can’t perform that action at this time.
0 commit comments