<div dir="ltr">Hello everyone,<div><br></div><div>sorry for the multiple mails but I think I found my issue. In the documentation I discovered this:</div><div><br></div><div><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">"Note that<span> </span></span><a href="https://www.gnutls.org/manual/html_node/Abstract-key-API.html#gnutls_005fpubkey_005fget_005fkey_005fid" style="font-family:"Times New Roman";font-size:medium;background-color:rgb(255,255,255)">gnutls_pubkey_get_key_id</a><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span> </span>calculates a SHA1 digest of the public key as a DER-formatted, subjectPublicKeyInfo object. Other implementations use different approaches, e.g., some use the “common method” described in section 4.2.1.2 of [</span><a href="https://www.gnutls.org/manual/html_node/Bibliography.html#RFC5280" style="font-family:"Times New Roman";font-size:medium;background-color:rgb(255,255,255)">RFC5280</a><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">] which calculates a digest on a part of the subjectPublicKeyInfo object.</span> "</div><div><br></div><div>Is it with gnutls possible to generate the key id with one of the "common methods" described in RFC5280?<br></div><div><br></div><div>Regards,</div><div>ckmk14</div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-07-16 15:06 GMT+02:00 Markus Karch <span dir="ltr"><<a href="mailto:dietmakarch@gmail.com" target="_blank">dietmakarch@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I am creating a self signed X.509 certificate and trying to set the SKI and the AKI. </div><div>These values should be the SHA-1 of the public key.</div><div>But when I am settign these values I am only getting the SHA-1 hash value of the private key.</div><div>What am I doing wrong? Here is a code snippet :</div><div><br></div><div> <pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono""><span style="color:rgb(55,31,128)">gnutls_x509_crt_t </span>crt;<br><span style="color:rgb(55,31,128)">gnutls_x509_privkey_t </span>privKey;<br><br>gnutls_x509_crt_init(&crt);<br>gnutls_x509_privkey_init(&<wbr>privKey);<br><br><span style="color:rgb(0,0,128);font-weight:bold">int </span>gnuErr = gnutls_x509_privkey_generate(<wbr>privKey, <span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">GNUTLS_PK_RSA</span>, <span style="color:rgb(0,0,255)">2048</span>, <span style="color:rgb(0,0,255)">0</span>);<br>gnuErr = gnutls_x509_crt_set_dn (crt, <span style="color:rgb(0,128,0);font-weight:bold">"O=test,CN=test"</span>, <span style="color:rgb(31,84,46);font-weight:bold">NULL</span>);<br>gnuErr = gnutls_x509_crt_set_key(crt, privKey);<br>gnutls_x509_crt_set_version(<wbr>crt, <span style="color:rgb(0,0,255)">3</span>);<br><span style="color:rgb(0,0,128);font-weight:bold">int </span>serialNumber = rand();<br>gnuErr = gnutls_x509_crt_set_serial(<wbr>crt, &serialNumber, <span style="color:rgb(0,0,128);font-weight:bold">sizeof</span>(<span style="color:rgb(0,0,128);font-weight:bold">int</span>));<br><br><span style="color:rgb(128,128,128);font-style:italic">//Here is the problem<br></span><span style="color:rgb(55,31,128)">gnutls_pubkey_t </span>pubKey;<br>gnuErr = gnutls_pubkey_init(&pubKey);<br>gnuErr =  gnutls_pubkey_import_x509(<wbr>pubKey, crt,<span style="color:rgb(0,0,255)">0 </span>);<br><span style="color:rgb(0,0,128);font-weight:bold">unsigned char </span>test[<span style="color:rgb(0,0,255)">20</span>]; <span style="color:rgb(128,128,128);font-style:italic">// Normally 20 bytes (SHA1)<br></span><span style="color:rgb(55,31,128)">size_t </span>size = <span style="color:rgb(0,0,128);font-weight:bold">sizeof</span>(test);<br><span style="color:rgb(128,128,128);font-style:italic">//Here I am getting the hash of the private key <br></span>gnuErr = gnutls_pubkey_get_key_id(<wbr>pubKey, <span style="color:rgb(0,0,255)">0</span>, test, &size);<br>gnuErr = gnutls_x509_crt_set_subject_<wbr>key_id(crt, test, size);</pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono"">//....</pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono"">Regards, 
ckmk14</pre></div></div>
</blockquote></div><br></div>