public static Subject createSubject(File certKeyFile) { try { X509CertificateChain certKey = readPemCertificateAndKey(certKeyFile); return AuthenticationUtil.getSubject(certKey); } catch (InvalidKeySpecException ex) { throw new RuntimeException("failed to read RSA private key from " + certKeyFile, ex); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("BUG: failed to create empty KeyStore", ex); } catch (IOException ex) { throw new RuntimeException("failed to read certificate file " + certKeyFile, ex); } catch (CertificateException ex) { throw new RuntimeException("failed to load certificate from file " + certKeyFile, 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); } }