<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi all,<div><br></div><div>I'm encountering an error connecting to a device which as far as I can see has a reasonable certificate...</div><div><br></div><div>The error coming back (through twisted and python) is:</div></div><div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">twisted.python.failure.Failure OpenSSL.SSL.Error: [('asn1 encoding routines', 'c2i_ibuf', 'illegal padding'), ('asn1 encoding routines', 'asn1_template_noexp_d2i', 'nested asn1 error'), ('asn1 encoding routines', 'asn1_template_noexp_d2i', 'nested asn1 error'), ('SSL routines', 'tls_process_server_certificate', 'ASN1 lib')]</blockquote><div><br></div><div>However if I run the following:</div><div><font face="monospace"># openssl s_client -connect <host>:<port> </dev/null 2>/dev/null | openssl x509 | openssl asn1parse<br></font></div><div><div><font face="monospace">    0:d=0  hl=4 l= 733 cons: SEQUENCE</font></div><div><font face="monospace">    4:d=1  hl=4 l= 453 cons: SEQUENCE</font></div><div><font face="monospace">    8:d=2  hl=2 l=   3 cons: cont [ 0 ]</font></div><div><font face="monospace">   10:d=3  hl=2 l=   1 prim: INTEGER           :02</font></div><div><font face="monospace">   13:d=2  hl=2 l=   4 prim: INTEGER           :000000</font></div><div><font face="monospace">   19:d=2  hl=2 l=  13 cons: SEQUENCE</font></div><div><font face="monospace">   21:d=3  hl=2 l=   9 prim: OBJECT            :sha256WithRSAEncryption</font></div></div><div><font face="monospace">   ... (continues)</font></div><div><br></div><div>...then OpenSSL seems to handle the whole certificate without problem, the thing that looks "off" to me is the serial number being defined as "000000", rather than "00" (which I see on the self signed certificates from other devices of this type).</div><div><br></div><div>Is that likely to be causing the issue?  It's ~20 years since I last had to deal with ASN.1 properly, so I can't remember if using unnecessarily long representations of integers is actually valid.</div><div><br></div><div>The raw ASN.1 looks ok I *think* (although I note that it has four bytes specified) "<font face="monospace">02 04 00 00 00 00</font>"</div><div><br></div><div><br></div><div>I'm at the point where I might just try to get it to generate a new certificate and see if it does that with a single byte zero (as per the other similar device I've been looking at)</div><div><br></div><div>Am I completely barking up the wrong tree, is there something else that I can use other than the asn1parse option to figure out where the error might be coming from?</div><div><br></div><div>Cheers,</div><div><br></div><div>John</div><div><br></div></div><div dir="ltr"><div>-- <br></div><div><div dir="ltr" class="gmail_signature"><span style="font-size:12px"><strong>John Robson<br></strong></span><span style="font-size:12px"><br>
</span></div></div></div></div></div></div>