Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8061773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:27:02+00:00 2026-06-05T10:27:02+00:00

Follow-up to this one . I got the reading/decoding working 1> {ok, F} =

  • 0

Follow-up to this one.

I got the reading/decoding working

1> {ok, F} = file:read_file("inaimathi.rsapub").
{ok,<<"-----BEGIN RSA PUBLIC KEY-----\nmQINBE9NBIQBEADMSzN6b0FaPP0rGiLDWKfH4ehN66Z0SAIynXm6lBHjmO69pNsm\niIe4p1X9aXhr"...>>}
2> [Entry] = public_key:pem_decode(F).
[{'RSAPublicKey',<<153,2,13,4,79,77,4,132,1,16,0,204,75,
                   51,122,111,65,90,60,253,43,26,34,195,
                   88,167,...>>,
                 not_encrypted}]

According to the docs, the last thing I have to do in order to get a working public key out of this is run public_key:pem_entry_decode/1 on that Entry. However, when I try to do that, I get an eror.

3> public_key:pem_entry_decode(Entry).
** exception error: no match of right hand side value 
                    {error,
                        {asn1,
                            {{badmatch,{error,{asn1,{wrong_tag,{131097,16}}}}},
                             [{'OTP-PUB-KEY',dec_RSAPublicKey,2,
                                  [{file,"OTP-PUB-KEY.erl"},{line,5956}]},
                              {'OTP-PUB-KEY',decode,2,
                                  [{file,"OTP-PUB-KEY.erl"},{line,493}]},
                              {public_key,der_decode,2,
                                  [{file,"public_key.erl"},{line,166}]},
                              {erl_eval,do_apply,6,
                                  [{file,"erl_eval.erl"},{line,576}]},
                              {shell,exprs,7,[{file,"shell.erl"},{line,668}]},
                              {shell,eval_exprs,7,
                                  [{file,"shell.erl"},{line,623}]},
                              {shell,eval_loop,3,
                                  [{file,"shell.erl"},{line,608}]}]}}}
     in function  public_key:der_decode/2 (public_key.erl, line 170)

What am I doing wrong here?

EDIT: Didn’t think it would matter, but someone asked, so.

I’m running Debian Wheezy on a Core i3 with Erlang installed from a ~2 day old checkout of this.

erl --version says

Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:27:04+00:00Added an answer on June 5, 2026 at 10:27 am

    Your code works fine here:

    decode() ->
        [application:start(X) || X <- [crypto, public_key, ssl]],
        RawData = ["-----BEGIN PUBLIC KEY-----\n",
                   "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBm8yuHmd0P6scl48DEi+xp47w\n",
                   "XVZaKWRygGKtA2XkdRuCU99f0Tq07Llcgf8XuR+Wnk+z2CdMMFMzOGhCePblVIAn\n",
                   "33dcBVlDokpBF7AnTClsaLcixxZw1LIUiaPaBdN7oG8vt3G2caLHRrrkoEnccY+6\n",
                   "GadfH7iuHdcVsz1mowIDAQAB\n",
                   "-----END PUBLIC KEY-----"],
        D = iolist_to_binary(RawData),
        [Entry] = public_key:pem_decode(D),
        public_key:pem_entry_decode(Entry).
    

    Generates output (shortened):

     {'RSAPublicKey',135956...,65537}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is a follow on from this one ... I am binding to
If you follow this link to one of the pages on my site and
This is like a follow-up question to this one . Basically what I'm doing
This is a follow-up question to this one . Consider this example: #include <iostream>
I have a follow-up question to this one . I created a new form,
I have a follow up question to this one . Now that I have
Just a follow up question to this one here => link Is it possible
This is a follow-up questions on a previous one . Consider this code, which
This is a follow-on question from the one I asked here . Can constraints
This is really a follow on question to a previous one , where I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.