aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public_key
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2011-02-17 11:20:06 +0100
committerIngela Anderton Andin <[email protected]>2011-02-17 11:20:06 +0100
commit397d9f598aaa1f84706f45565b0f347eea502820 (patch)
treeb7cbff76427abb9954b077d5559a9396bb0ef748 /lib/public_key
parent1ec3f9518d94989a0596e5e8aa62d3ce48d89101 (diff)
downloadotp-397d9f598aaa1f84706f45565b0f347eea502820.tar.gz
otp-397d9f598aaa1f84706f45565b0f347eea502820.tar.bz2
otp-397d9f598aaa1f84706f45565b0f347eea502820.zip
Strip new lines at end of PEM entry when comparing as it may be more than one
Diffstat (limited to 'lib/public_key')
-rw-r--r--lib/public_key/test/public_key_SUITE.erl12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/public_key/test/public_key_SUITE.erl b/lib/public_key/test/public_key_SUITE.erl
index e74ff8051d..185618e58e 100644
--- a/lib/public_key/test/public_key_SUITE.erl
+++ b/lib/public_key/test/public_key_SUITE.erl
@@ -146,7 +146,8 @@ pk_decode_encode(Config) when is_list(Config) ->
DSAPubKey = public_key:pem_entry_decode(PubEntry0),
true = check_entry_type(DSAPubKey, 'DSAPublicKey'),
PubEntry0 = public_key:pem_entry_encode('SubjectPublicKeyInfo', DSAPubKey),
- DSAPubPem = public_key:pem_encode([PubEntry0]),
+ DSAPubPemNoEndNewLines = strip_ending_newlines(DSAPubPem),
+ DSAPubPemEndNoNewLines = strip_ending_newlines(public_key:pem_encode([PubEntry0])),
[{'RSAPrivateKey', DerRSAKey, not_encrypted} = Entry1 ] =
erl_make_certs:pem_to_der(filename:join(Datadir, "client_key.pem")),
@@ -167,13 +168,15 @@ pk_decode_encode(Config) when is_list(Config) ->
RSAPubKey = public_key:pem_entry_decode(PubEntry1),
true = check_entry_type(RSAPubKey, 'RSAPublicKey'),
PubEntry1 = public_key:pem_entry_encode('SubjectPublicKeyInfo', RSAPubKey),
- RSAPubPem = public_key:pem_encode([PubEntry1]),
+ RSAPubPemNoEndNewLines = strip_ending_newlines(RSAPubPem),
+ RSAPubPemNoEndNewLines = strip_ending_newlines(public_key:pem_encode([PubEntry1])),
{ok, RSARawPem} = file:read_file(filename:join(Datadir, "rsa_pub_key.pem")),
[{'RSAPublicKey', _, _} = PubEntry2] =
public_key:pem_decode(RSARawPem),
RSAPubKey = public_key:pem_entry_decode(PubEntry2),
- RSARawPem = public_key:pem_encode([PubEntry2]),
+ RSARawPemNoEndNewLines = strip_ending_newlines(RSARawPem),
+ RSARawPemNoEndNewLines = strip_ending_newlines(public_key:pem_encode([PubEntry2])),
Salt0 = crypto:rand_bytes(8),
Entry3 = public_key:pem_entry_encode('RSAPrivateKey', RSAKey0,
@@ -464,3 +467,6 @@ check_entry_type(#'Certificate'{}, 'Certificate') ->
true;
check_entry_type(_,_) ->
false.
+
+strip_ending_newlines(Bin) ->
+ string:strip(binary_to_list(Bin), right, 10).