diff options
author | Ingela Anderton Andin <[email protected]> | 2016-03-02 09:48:28 +0100 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2016-03-02 09:48:28 +0100 |
commit | 8e7fa634e2e2ab1e4f450b3cfb8a4ee8f96eaae8 (patch) | |
tree | 01db35904541d01f7ec8d033124ae3eb775d7306 | |
parent | e73a3bbdb15d35b9b03d140ed40bd6bae8b408cc (diff) | |
parent | 72398fd081732a599dba183b26cc056bd310eba1 (diff) | |
download | otp-8e7fa634e2e2ab1e4f450b3cfb8a4ee8f96eaae8.tar.gz otp-8e7fa634e2e2ab1e4f450b3cfb8a4ee8f96eaae8.tar.bz2 otp-8e7fa634e2e2ab1e4f450b3cfb8a4ee8f96eaae8.zip |
Merge branch 'maint'
-rw-r--r-- | lib/public_key/src/pubkey_pem.erl | 2 | ||||
-rw-r--r-- | lib/public_key/test/public_key_SUITE.erl | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/public_key/src/pubkey_pem.erl b/lib/public_key/src/pubkey_pem.erl index 6a722b0525..d163004c7c 100644 --- a/lib/public_key/src/pubkey_pem.erl +++ b/lib/public_key/src/pubkey_pem.erl @@ -103,7 +103,7 @@ encode_pem_entry({'PrivateKeyInfo', Der, EncParams}) -> [StartStr, "\n", b64encode_and_split(EncDer), "\n", pem_end(StartStr) ,"\n\n"]; encode_pem_entry({Type, Der, {Cipher, Salt}}) -> StartStr = pem_start(Type), - [StartStr,"\n", pem_decrypt(),"\n", pem_decrypt_info(Cipher, Salt),"\n", + [StartStr,"\n", pem_decrypt(),"\n", pem_decrypt_info(Cipher, Salt),"\n\n", b64encode_and_split(Der), "\n", pem_end(StartStr) ,"\n\n"]. decode_pem_entries([], Entries) -> diff --git a/lib/public_key/test/public_key_SUITE.erl b/lib/public_key/test/public_key_SUITE.erl index 5e677f31d6..ea5e036a7e 100644 --- a/lib/public_key/test/public_key_SUITE.erl +++ b/lib/public_key/test/public_key_SUITE.erl @@ -189,6 +189,8 @@ encrypted_pem(Config) when is_list(Config) -> erl_make_certs:der_to_pem(DesKeyFile, [Entry1]), [{'RSAPrivateKey', _, {"DES-CBC", Salt1}} =Entry2] = erl_make_certs:pem_to_der(DesKeyFile), + {ok, Pem} = file:read_file(DesKeyFile), + check_encapsulated_header(Pem), true = check_entry_type(public_key:pem_entry_decode(Entry2, "4567efgh"), 'RSAPrivateKey'). @@ -826,6 +828,15 @@ check_entry_type(#'Certificate'{}, 'Certificate') -> check_entry_type(_,_) -> false. +check_encapsulated_header(Pem) when is_binary(Pem)-> + check_encapsulated_header( binary:split(Pem, <<"\n">>, [global])); +check_encapsulated_header([<<"DEK-Info: DES-CBC,FB7577791A9056A1">>, <<>> | _]) -> + true; +check_encapsulated_header([ _ | Rest]) -> + check_encapsulated_header(Rest); +check_encapsulated_header([]) -> + false. + strip_ending_newlines(Bin) -> string:strip(binary_to_list(Bin), right, 10). |