From a3a586abbe92e2d0b6076f15044b1d19d445b470 Mon Sep 17 00:00:00 2001 From: smallbun <2689170096@qq.com> Date: Thu, 9 Feb 2023 09:59:10 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E5=A4=9A=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E6=8D=A2=E8=A1=8C=E7=AC=A6BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../topiam/employee/common/util/X509Utilities.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/util/X509Utilities.java b/eiam-common/src/main/java/cn/topiam/employee/common/util/X509Utilities.java index cda48814..4490f3fe 100644 --- a/eiam-common/src/main/java/cn/topiam/employee/common/util/X509Utilities.java +++ b/eiam-common/src/main/java/cn/topiam/employee/common/util/X509Utilities.java @@ -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(); } -} +} \ No newline at end of file