"known in advance" public key authentication?

Ivan Shmakov oneingray at gmail.com
Sun Nov 11 15:59:34 CET 2012

>>>>> Nikos Mavrogiannopoulos <nmav at gnutls.org> writes:
>>>>> On 11/07/2012 05:32 PM, Ivan Shmakov wrote:


 >> To put it short, the application in question uses “self-certified
 >> identifiers”; i. e., the public key /is/ the identifier of the peer.
 >> Thus, there doesn't seem to be any reason whatsoever to sign the
 >> public keys used, and both X.509 and OpenPGP hence become of little
 >> use.

 > Currently you cannot avoid using a container for the public keys,
 > either X.509 or Openpgp.

	Do I understand it correctly that it's a requirement of the TLS
	protocol itself?

	As for the implementation, gnutls_certificate_set_x509_key ()
	assumes that at least one certificate is available, and, AIUI,
	GnuTLS will try to find the “best” matching certificate
	associated with the credentials sometime later (during

 > You may completely ignore it after that and only compare the raw
 > keys, or their identifiers e. g. with by using one of the
 > _get_key_id () functions.

	ACK, thanks!

	What'd be the simplest code to craft a self-signed certificate
	out of a gnutls_x509_privkey_t instance?

	I guess, it'd be something along the lines of:

  gnutls_x509_crt_t crt;
    /* craft a dummy certificate */
    int ra
      = gnutls_x509_crt_init (&crt);
    assert (ra == 0);
    int rb
      = gnutls_x509_crt_set_key (crt, priv);
    assert (rb == 0);
    /* NB: doesn't accept empty strings */
    int rc
      = gnutls_x509_crt_set_dn_by_oid (crt, GNUTLS_OID_X520_COMMON_NAME,
                                       0, "Foo!", 4);
    assert (rc == 0);
    /* FIXME: what else to call? */

FSF associate member #7257

More information about the Gnutls-help mailing list