List of usage examples for com.amazonaws.auth PEM readPrivateKey
public static PrivateKey readPrivateKey(InputStream is) throws InvalidKeySpecException, IOException
From source file:org.nuxeo.ecm.core.storage.sql.CloudFrontBinaryManager.java
License:Apache License
private static PrivateKey loadPrivateKey(String privateKeyPath) throws InvalidKeySpecException, IOException { if (privateKeyPath == null) { return null; }/*from ww w. j av a 2 s.c o m*/ try (FileInputStream is = new FileInputStream(new File(privateKeyPath))) { if (privateKeyPath.toLowerCase().endsWith(".pem")) { return PEM.readPrivateKey(is); } if (privateKeyPath.toLowerCase().endsWith(".der")) { return RSA.privateKeyFromPKCS8(IOUtils.toByteArray(is)); } throw new AmazonClientException("Unsupported file type for private key"); } }