File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
utils/src/main/java/com/cloud/utils/ssh Expand file tree Collapse file tree 1 file changed +7
-1
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 ;
2324import java .math .BigInteger ;
2425import java .nio .ByteBuffer ;
2526import java .nio .charset .StandardCharsets ;
3132
3233import org .apache .cloudstack .utils .security .CertUtils ;
3334import org .apache .commons .codec .binary .Base64 ;
35+ import org .bouncycastle .openssl .jcajce .JcaPEMWriter ;
3436
3537public class SSHKeysHelper {
3638
@@ -146,7 +148,11 @@ public String getPrivateKey() {
146148 return null ;
147149 }
148150 try {
149- return CertUtils .privateKeyToPem (keyPair .getPrivate ());
151+ StringWriter sw = new StringWriter ();
152+ try (JcaPEMWriter pemWriter = new JcaPEMWriter (sw )) {
153+ pemWriter .writeObject (keyPair .getPrivate ());
154+ }
155+ return sw .toString ();
150156 } catch (Exception e ) {
151157 e .printStackTrace ();
152158 }
You can’t perform that action at this time.
0 commit comments