CertUtil { public static String getInfoString(String cert) throws CertificateException { return getInfoString(parseCert(Objects.requireNonNull(cert))); } private  CertUtil(); static X509Certificate getServerRoot(); static X509Certificate getPluginRoot(); static X509Certificate getDefaultCert(); static PrivateKey getDefaultKey(); static boolean checkValidity(X509Certificate cert); static boolean checkHostname(X509Certificate cert, String hostname); static X509Certificate parseCert(String cert); static X509Certificate parseCert(File cert); static X509Certificate parseCert(byte[] cert); static PrivateKey parseKey(byte[] key); static String getInfoString(String cert); static String getInfoString(X509Certificate cert); static String getInfoHtml(X509Certificate cert);  }
@Test @DisplayName("Check the format of a certificate's info string") void getInfoString_1() throws CertificateException { assertEquals( "Signature:(SHA1withRSA)1.2.840.113549.1.9.1=#161f61646d696e4073756274657272616e65616e2d73656375726974792e636f6d,CN=debug,OU=SubterraneanSecurity,O=SubterraneanSecurity,ST=Texas,C=USValidityNotBefore:" + (new Date(1495861281000L) + "NotAfter:" + new Date(1527397281000L)).replaceAll("\\s", "") + "Publickey:(RSA)30:82:01:22:30:0d:06:09:2a:86:48:86:f7:0d:01:01:01:05:00:03:82:01:0f:00:30:82:01:0a:02:82:01:01:00:af:89:9d:3c:c6:7a:53:9f:1b:5d:f8:63:25:72:73:09:db:2c:67:61:f2:d8:ba:0e:b2:e5:d2:b5:35:fb:d1:dc:ab:9b:6b:33:45:b3:65:bb:2e:47:c1:a6:21:57:82:96:7d:32:7b:1c:a1:91:9b:ad:cb:1d:2d:99:e1:1e:84:07:03:2a:23:38:57:69:09:ac:2c:d6:4b:8c:5a:6e:25:64:fb:44:c9:51:2f:81:2f:9e:71:f4:d6:30:5c:45:1b:cc:85:67:18:ca:e8:90:93:d0:e1:54:29:fb:4e:87:23:6f:61:6f:dc:af:17:3d:8c:b7:7b:6a:a6:db:bd:ee:41:96:d9:30:9a:51:3e:e4:90:66:e9:f3:45:a9:75:5e:1a:46:02:fe:48:2d:ab:cb:0d:9c:66:d3:ff:f5:9e:43:35:f2:8b:a1:bc:3c:c5:c6:ff:f7:12:23:37:83:26:e9:1e:8b:4d:eb:05:ae:19:de:61:0d:2c:76:9b:60:c4:85:0c:6e:c6:98:9f:03:2a:c1:3f:6e:b9:04:b5:96:93:70:f6:b2:74:9a:2d:71:bf:39:26:c4:47:db:85:90:d7:1e:1c:90:d5:e5:8d:3b:e2:a7:27:8e:37:24:0e:26:98:11:44:64:fc:52:ca:f9:13:95:02:9f:66:b5:ca:db:6c:74:ef:a5:02:03:01:00:01", CertUtil.getInfoString(testCert).replaceAll("\\s", "")); }