|
|
@ -46,10 +46,11 @@ import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class X509Utilities {
|
|
|
|
public class X509Utilities {
|
|
|
|
|
|
|
|
|
|
|
|
public static final String BEGIN_CERT = "-----BEGIN CERTIFICATE-----";
|
|
|
|
public static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
|
|
|
public static final String END_CERT = "-----END CERTIFICATE-----";
|
|
|
|
public static final String BEGIN_CERT = "-----BEGIN CERTIFICATE-----" + LINE_SEPARATOR;
|
|
|
|
public static final String BEGIN_KEY = "-----BEGIN RSA PRIVATE KEY-----";
|
|
|
|
public static final String END_CERT = "-----END CERTIFICATE-----";
|
|
|
|
public static final String END_KEY = "-----END RSA PRIVATE KEY-----";
|
|
|
|
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) {
|
|
|
|
public static byte[] getDer(String combinedKeyAndCertPem, String begin, String end) {
|
|
|
|
String[] tokens = combinedKeyAndCertPem.split(begin);
|
|
|
|
String[] tokens = combinedKeyAndCertPem.split(begin);
|
|
|
@ -65,7 +66,7 @@ public class X509Utilities {
|
|
|
|
|
|
|
|
|
|
|
|
public static String keyCleanup(String pem) {
|
|
|
|
public static String keyCleanup(String pem) {
|
|
|
|
return pem.replace(BEGIN_CERT, "").replace(END_CERT, "").replace(BEGIN_KEY, "")
|
|
|
|
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 {
|
|
|
|
public static X509Certificate getCertificate(byte[] der) throws CertificateException {
|
|
|
|