@SuppressWarnings("unchecked") public static X509Certificate[] readCertificateChain(File certFile) throws CertificateException, IOException { try { X509Certificate[] chain = readCertificateChain(FileUtil.readFile(certFile)); log.debug("X509 certificate is valid"); return chain; } catch (CertificateException ex) { throw new RuntimeException("certificate from file " + certFile + " is not valid", ex); } }
public static Subject createSubject(File certFile, File keyFile) { try { PrivateKey pk = readPrivateKey(keyFile); X509Certificate[] chain = readCertificateChain(certFile); return AuthenticationUtil.getSubject(chain, pk); } catch (InvalidKeySpecException ex) { throw new RuntimeException("failed to read RSA private key from " + keyFile, ex); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("BUG: failed to create empty KeyStore", ex); } catch (FileNotFoundException ex) { throw new RuntimeException("failed to find certificate and/or key file " + certFile + "," + keyFile, ex); } catch (IOException ex) { throw new RuntimeException("failed to read certificate file " + certFile, ex); } catch (CertificateException ex) { throw new RuntimeException("failed to load certificate from file " + certFile, ex); } }
private static KeyStore getKeyStore(File certFile, File keyFile) { try { PrivateKey pk = readPrivateKey(keyFile); Certificate[] chain = readCertificateChain(certFile); return getKeyStore(chain, pk); } catch (InvalidKeySpecException ex) { throw new RuntimeException("failed to read RSA private key from " + keyFile, ex); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("BUG: failed to create empty KeyStore", ex); } catch (FileNotFoundException ex) { throw new RuntimeException("failed to find certificate and/or key file " + certFile + "," + keyFile, ex); } catch (IOException ex) { throw new RuntimeException("failed to read certificate file " + certFile, ex); } catch (CertificateException ex) { throw new RuntimeException("failed to load certificate from file " + certFile, ex); } }
.readCertificateChain(SSLUtil .getCertificates(certBuf)); return certs;
X509Certificate[] chain = readCertificateChain(certificates);