mirror of https://gitee.com/topiam/eiam
🐛 修复多平台换行符BUG
parent
289d0b2a77
commit
a3a586abbe
|
@ -46,10 +46,11 @@ import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
|
|||
*/
|
||||
public class X509Utilities {
|
||||
|
||||
public static final String BEGIN_CERT = "-----BEGIN CERTIFICATE-----";
|
||||
public static final String END_CERT = "-----END CERTIFICATE-----";
|
||||
public static final String BEGIN_KEY = "-----BEGIN RSA PRIVATE KEY-----";
|
||||
public static final String END_KEY = "-----END RSA PRIVATE KEY-----";
|
||||
public static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
public static final String BEGIN_CERT = "-----BEGIN CERTIFICATE-----" + LINE_SEPARATOR;
|
||||
public static final String END_CERT = "-----END CERTIFICATE-----";
|
||||
public static final String BEGIN_KEY = "-----BEGIN RSA PRIVATE KEY-----" + LINE_SEPARATOR;
|
||||
public static final String END_KEY = "-----END RSA PRIVATE KEY-----";
|
||||
|
||||
public static byte[] getDer(String combinedKeyAndCertPem, String begin, String end) {
|
||||
String[] tokens = combinedKeyAndCertPem.split(begin);
|
||||
|
@ -65,7 +66,7 @@ public class X509Utilities {
|
|||
|
||||
public static String keyCleanup(String pem) {
|
||||
return pem.replace(BEGIN_CERT, "").replace(END_CERT, "").replace(BEGIN_KEY, "")
|
||||
.replace(END_KEY, "").replace("\n", "").trim().replace("\r","");
|
||||
.replace(END_KEY, "").replace("\n", "").trim();
|
||||
}
|
||||
|
||||
public static X509Certificate getCertificate(byte[] der) throws CertificateException {
|
||||
|
@ -133,4 +134,4 @@ public class X509Utilities {
|
|||
return kp.getPublic();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue