I want to authenticate with client SSL certificate. Here is my code
my $ua = LWP::UserAgent->new( ssl_opts => { #SSL_version => 'SSLv3', verify_hostname => 0, SSL_cert_file => "./cert.pem", SSL_cert_key => "./key.pem" } ); my $res = $ua->get($query);
I have two questions regarding this.

1. Why is in documentation of IO::Socket::SSL that I can set SSL_version to SSLv3 and when I do so, I get error that this version is not supported?

2. In which format should the key be in? I tried following formats:

a) PEM format = other tools and openssl also works fine with this format so I guess the file is not modified in some weird way.
b) DER format = I converted from PEM format with: openssl rsa -in key.pem -pubout -outform DER -out key.der .... converted with no errors.
c) DER format = I converted from PEM format with: openssl pkcs8 -topk8 -inform PEM -outform DER -in key.pem -out key.der -nocrypt .... converted with no errors.
d) I also tried format that is output of: openssl rsa -in key.pem -text > key1.pem

But every single one yields this error:

DEBUG: .../IO/Socket/SSL.pm:2582: Failed to load key from file (no PEM or DER)
SSL error: 19240: 1 - error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error
SSL error: 19240: 2 - error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag
SSL error: 19240: 3 - error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error
SSL error: 19240: 4 - error:04093004:rsa routines:old_rsa_priv_decode:RSA lib
SSL error: 19240: 5 - error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag
SSL error: 19240: 6 - error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error
SSL error: 19240: 7 - error:140B000D:SSL routines:SSL_CTX_use_PrivateKey_file:ASN1 lib
DEBUG: .../IO/Socket/SSL.pm:2582: global error: Failed to load key from file (no PEM or DER) error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag


In reply to LWP::UserAgent Client certificate authentication by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.