[erlang-questions] Dealing with public/private keys stored in*.pem files ( resending as plain text )

Daniel Kwiecinski <>
Thu Jan 31 17:05:55 CET 2008


> > > >Hi,
> > > >
> > > >     As far as I know the crypto module (app) handles rsa's private keys as a list of two binaries (exponent and modulus). How can I obtain these from base64 encoded *.pem files?
> > > >
> > > >  --
> > > >  Kind Regards,
> > > >  Daniel Kwiecinski


> > >Hi,
> > >  there is not yet a public api for this in OTP. However, the undocumented, unsupported function ssl_pkix:decode_rsa_keyfile/2 does just this. It reads a .pem keyfile and returns a record with exponent and modulus, and other fields. It is unsupported, so it might be moved (or even removed) in future releases of OTP.
> > >  /Jakob


> > Eshell V5.5.5  (abort with ^G)
> >  1> ssl_pkix:decode_rsa_keyfile("public.pem").
> >  ** exited: {undef,[{ssl_pkix,decode_rsa_keyfile,["public.pem"]},
> >                     {erl_eval,do_apply,5},
> >                     {shell,exprs,6},
> >                     {shell,eval_loop,3}]} **
> >
> >  =ERROR REPORT==== 31-Jan-2008::14:11:10 ===
> >  Error in process <0.31.0> with exit value: {undef,[{ssl_pkix,decode_rsa_keyfile,["public.pem"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
> >
> >  2> ssl_pkix:decode_cert_file("public.pem", [pem]).
> >
> >  =ERROR REPORT==== 31-Jan-2008::14:11:22 ===
> >  Error in process <0.33.0> with exit value: {{badmatch,{ok,[]}},[{ssl_pkix,decode_cert_file,2},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
> >
> >  ** exited: {{badmatch,{ok,[]}},
> >              [{ssl_pkix,decode_cert_file,2},
> >               {erl_eval,do_apply,5},
> >               {shell,exprs,6},
> >               {shell,eval_loop,3}]} **
> >
> >  :-( Daniel

> Hi,
>
>
>
> Ssl_pkix:decode_rsa_keyfile is returning undefined because it requires two parameters, namely Key File and Password
>
>
>
> Trevor



There is no such function 'decode_rsa_keyfile' at all in 'ssl_pkix'
module in erts v5.5.5

Eshell V5.5.5  (abort with ^G)
1> m(ssl_pkix).
 Module ssl_pkix compiled: Date: June 11 2007, Time: 17.57
Compiler options:  [{d,'VSN',"3.1.1.1"},

{cwd,"/ldisk/daily_build/otp_prebuild_r11b.2007-06-11_19/otp_src_R11B-5/lib/ssl/src"},

{outdir,"/ldisk/daily_build/otp_prebuild_r11b.2007-06-11_19/otp_src_R11B-5/lib/ssl/src/../ebin"},

{i,"/ldisk/daily_build/otp_prebuild_r11b.2007-06-11_19/otp_src_R11B-5/lib/kernel/src"},

{i,"/ldisk/daily_build/otp_prebuild_r11b.2007-06-11_19/otp_src_R11B-5/lib/ssl/src/../include"},
                     warn_unused_vars,
                    debug_info]
 Object file: /sw/lib/erlang/lib/ssl-3.1.1.1/ebin/ssl_pkix.beam
Exports:
          decode_cert/1
         decode_cert/2
          decode_cert_file/1
         decode_cert_file/2
          module_info/0
         module_info/1
 ok

:-(    Daniel



More information about the erlang-questions mailing list