@Test
public void readNonEncryptedPemPrivateKey() throws Exception {

    // non encrypted private key
    Path path = Paths.get(getClass().getResource("/ssl/server.pem").toURI());
    PrivateKey privateKey = PrivateKeyReader.fromPem(path, null);
    assertNotNull(privateKey);
    assertEquals("PKCS#8", privateKey.getFormat());
    try {
        PrivateKeyReader.fromPem(path, "");
        fail("Should fail with empty password");
    } catch (Exception ex) {
    }
    try {
        PrivateKeyReader.fromPem(path, "password");
        fail("Should fail with any password for non encrypted key");
    } catch (Exception ex) {
    }
}