[erlang-questions] public_key:pem_decode/1 and public_key:verify/4

caox caox@REDACTED
Wed Jan 19 10:49:57 CET 2011


Maybe the asn1 type of your key file is not supported by public_key.  You can check it and use openssl to convert the key format.

在 2011-1-19,下午5:23, Joakim G. 写道:

> Hi all,
> It seems that public_key:pem_decode/1 can't decode public
> keys.
> 
> I wanted use public_key:verify/4 to verify a digital signature
> and for that I used public_key:pem_decode/1 to extract the
> public key.
> 
> 26> {ok, Bin} = file:read_file("key.pub").
> {ok,<<"-----BEGIN RSA PUBLIC
> KEY-----\nMIGJAoGBAKhhZ8RrKaA0RWhjXJlSpTHd7/h6Luww9qeyUkEqBQyiCooZZGCYNle5C9TfRVJDUuxz"...>>}
> 27> rp(Bin).
> <<"-----BEGIN RSA PUBLIC
> KEY-----\nMIGJAoGBAKhhZ8RrKaA0RWhjXJlSpTHd7/h6Luww9qeyUkEqBQyiCooZZGCYNle5\nC9TfRVJDUuxzigvXuTh0tlba+9AyIe2hxAztjs43pSKy5VnnJlSjMBVDay8XmNjh\nlUxid/ZV2hDkKlwHDCnZjdZpeXqdtGbZ7o3N7wOBzJSRQ7kqzQHXAgMBAAE=\n-----END
> RSA PUBLIC KEY-----\n">>
> ok
> 28> public_key:pem_decode(Bin).
> []
> 
> That was a surprise.
> 
> Cheers
> /Jocke
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> 



More information about the erlang-questions mailing list