Hi Dan:

Dan Ribe wrote:
> Hi,
> 
> I am trying to read the private key from the memory buffer (code snippet
> below), But PEM_read_bio_PrivateKey() always returns an error : OpenSSL
> error: error:0906D06C:PEM routines:PEM_read_bio:no start line
> 
> Can anyone please point out what I am doing wrong here. I am pretty new to
> OpenSSL, so please excuse me if i have messed up the things !
> 
> Code Snippet :
> 
>     char *key = "-----BEGIN RSA PRIVATE KEY-----"
>     "jGK1T++C+Np4As+KoaO2NCiCBN5UQJRzXBsZvLDoN6IcfxJwXklp560jrKiIZ8VU"
>     "N2AZVq28yjqt3RYaRPn0xhbmLfWH/o+wzlg58wIDAQABAoIBAAHEep7qWWMFWsbc"
> 
> ..............................................................................
> 
I think that you need \n characters at each "end of line". Otherwise,
you just have one long string, and the PEM_read functions don't
recognise that.

Patrick.


> ..............................................................................
> 
> 
>   "DwiD1OKnxTlAvZPkTSCS+QKBgDkXMM+2jyeRPwpUEyZjqYveVb5zc3HJMMGbpI/p"
>     "09dirkd+sRoXWShF8ctVVb4B1PAFTOBEa8diickehnAyEq6KhzLWpQqhqCnylETw"
>     "Drys2uVaAzmRhS6tGJ2fdwPnlSLJrQbHuP938BkyxNhdYN8drfqb"
>     "-----END RSA PRIVATE KEY-----";
> 
>     int keyLength = strlen(key);
>     BIO *bio = BIO_new_mem_buf(key, keyLength);
> 
>     EVP_PKEY *pktmp = NULL;
>     pktmp = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL);
> 
>     if (pktmp == NULL) {
>         char buffer[120];
> 
>         ERR_error_string(ERR_get_error(), buffer);
>         fprintf(stderr, "OpenSSL error: %s", buffer);
>     }
> 
> Thanks much for Help
> Cheers !
> 
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to