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

Ingela Andin <>
Wed Jan 19 14:21:53 CET 2011


Hi!

All possible PEM-types are not supported by public_key, the currently
supported types are mainly a result of what we need
for the ssl-application. More types may of course be added if there is
a need. You are welcome to contribute PEM-types that may be of common
use.

If you want the public part of your own rsa-key it is included in the
private-key and you can  decode that file with public_key and
pick out the public part.

Regards Ingela Erlang/OTP team - Ericsson AB


2011/1/19 caox <>:
> 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 (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
>
>


More information about the erlang-questions mailing list