class PrivateKeyReader {

    public static PrivateKey fromPem(Path path, String password) {
        PrivateKey privateKey;
        try {
            byte[] der = getDer(path);
            KeySpec keySpec = getKeySpec(der, password);
            KeyFactory kf = KeyFactory.getInstance("RSA");
            privateKey = kf.generatePrivate(keySpec);
        } catch (Exception e) {
            String msg = String.format("Failed to read PKCS#8 PEM file. file=%s", path);
            Utils.logWarning(msg);
            throw new RuntimeException(msg, e);
        }
        return privateKey;
    }

    private  PrivateKeyReader();

}