From 5db6a6d9c9f46785d1540aa1836bfa1a882934cf Mon Sep 17 00:00:00 2001 From: Lukas Schauer Date: Fri, 8 Jan 2016 22:10:09 +0100 Subject: [PATCH] Created Import existing account key (markdown) --- Import-existing-account-key.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Import-existing-account-key.md diff --git a/Import-existing-account-key.md b/Import-existing-account-key.md new file mode 100644 index 0000000..9fed5b9 --- /dev/null +++ b/Import-existing-account-key.md @@ -0,0 +1,32 @@ +If for any reason you want to import your existing account key from the official letsencrypt client place the following script next to `private_key.json` (should be in a subdirectory under `/etc/letsencrypt/accounts/acme-v01.api.letsencrypt.org/directory`) and run it. + +It should return your private key in PEM format, which you can pipe directly into `private_key.pem`. + +```perl +#!/usr/bin/env perl + +use strict; + +use Crypt::OpenSSL::RSA; +use Crypt::OpenSSL::Bignum; +use JSON; +use File::Slurp; +use MIME::Base64; + +my $json_file = "private_key.json"; +my $json_content = read_file($json_file); +$json_content =~ tr/-/+/; +$json_content =~ tr/_/\//; + +my $json = decode_json($json_content); + +my $n = Crypt::OpenSSL::Bignum->new_from_bin(decode_base64($json->{n})); +my $e = Crypt::OpenSSL::Bignum->new_from_bin(decode_base64($json->{e})); +my $d = Crypt::OpenSSL::Bignum->new_from_bin(decode_base64($json->{d})); +my $p = Crypt::OpenSSL::Bignum->new_from_bin(decode_base64($json->{p})); +my $q = Crypt::OpenSSL::Bignum->new_from_bin(decode_base64($json->{q})); + +my $rsa = Crypt::OpenSSL::RSA->new_key_from_parameters($n, $e, $d, $p, $q); + +print($rsa->get_private_key_string()); +``` \ No newline at end of file