@Test void testGenerateRsaPrivateKeyFromBytes() throws URISyntaxException, IOException { val keyPath = Paths.get(toUri("testdata/internal/privateKeyRsa.pem")); val keyBytes = Files.readAllBytes(keyPath); try { PrivateKey privateKey = CertificateUtils.generatePrivateKey(keyBytes, RSA, KeyFileFormat.PEM); assertNotNull(privateKey); assertEquals(RSA.value(), privateKey.getAlgorithm()); } catch (InvalidKeySpecException | InvalidKeyException | NoSuchAlgorithmException e) { fail("Should have generated key", e); } }
public static PrivateKey generatePrivateKey(final byte[] privateKeyBytes, AsymmetricKeyAlgorithm algorithm, KeyFileFormat keyFileFormat) throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException { EncodedKeySpec kspec = getEncodedKeySpec(privateKeyBytes, keyFileFormat); return generatePrivateKeyWithSpec(kspec, algorithm); }
CertificateUtils { public static PrivateKey generatePrivateKey(final byte[] privateKeyBytes, AsymmetricKeyAlgorithm algorithm, KeyFileFormat keyFileFormat) throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException { EncodedKeySpec kspec = getEncodedKeySpec(privateKeyBytes, keyFileFormat); return generatePrivateKeyWithSpec(kspec, algorithm); } }
CertificateUtils { public static PrivateKey generatePrivateKey(final byte[] privateKeyBytes, AsymmetricKeyAlgorithm algorithm, KeyFileFormat keyFileFormat) throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException { EncodedKeySpec kspec = getEncodedKeySpec(privateKeyBytes, keyFileFormat); return generatePrivateKeyWithSpec(kspec, algorithm); } private  CertificateUtils(); }
CertificateUtils { public static PrivateKey generatePrivateKey(final byte[] privateKeyBytes, AsymmetricKeyAlgorithm algorithm, KeyFileFormat keyFileFormat) throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException { EncodedKeySpec kspec = getEncodedKeySpec(privateKeyBytes, keyFileFormat); return generatePrivateKeyWithSpec(kspec, algorithm); } private  CertificateUtils(); static List<X509Certificate> generateCertificates(final byte[] input); static PrivateKey generatePrivateKey(final byte[] privateKeyBytes, AsymmetricKeyAlgorithm algorithm, KeyFileFormat keyFileFormat); static void validate(final List<X509Certificate> chain, final Collection<X509Certificate> trustedCerts); static SpiffeId getSpiffeId(final X509Certificate certificate); static TrustDomain getTrustDomain(final List<X509Certificate> chain); static void validatePrivateKey(final PrivateKey privateKey, final X509Certificate x509Certificate); static boolean isCA(final X509Certificate cert); static boolean hasKeyUsageCertSign(final X509Certificate cert); static boolean hasKeyUsageDigitalSignature(final X509Certificate cert); static boolean hasKeyUsageCRLSign(final X509Certificate cert); }
CertificateUtils { public static PrivateKey generatePrivateKey(final byte[] privateKeyBytes, AsymmetricKeyAlgorithm algorithm, KeyFileFormat keyFileFormat) throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException { EncodedKeySpec kspec = getEncodedKeySpec(privateKeyBytes, keyFileFormat); return generatePrivateKeyWithSpec(kspec, algorithm); } private  CertificateUtils(); static List<X509Certificate> generateCertificates(final byte[] input); static PrivateKey generatePrivateKey(final byte[] privateKeyBytes, AsymmetricKeyAlgorithm algorithm, KeyFileFormat keyFileFormat); static void validate(final List<X509Certificate> chain, final Collection<X509Certificate> trustedCerts); static SpiffeId getSpiffeId(final X509Certificate certificate); static TrustDomain getTrustDomain(final List<X509Certificate> chain); static void validatePrivateKey(final PrivateKey privateKey, final X509Certificate x509Certificate); static boolean isCA(final X509Certificate cert); static boolean hasKeyUsageCertSign(final X509Certificate cert); static boolean hasKeyUsageDigitalSignature(final X509Certificate cert); static boolean hasKeyUsageCRLSign(final X509Certificate cert);  }