Previous: Verifying a certificate in the context of TLS session, Up: X.509 certificates [Contents][Index]
It is possible to use a trust on first use (similar to SSH) authentication method in GnuTLS. That is the concept used by the SSH programs, where the public key of the peer is not verified, or verified in an out-of-bound way, but subsequent connections to the same peer require the public key to remain the same. Such a system in combination with the typical CA verification of a certificate, and OCSP revocation checks, can help to provide multiple factor verification, where a single point of failure is not enough to compromise the system. For example a server compromise may be detected using OCSP, and a CA compromise can be detected using the trust on first use method. Such a hybrid system with X.509 and trust on first use authentication is shown in Simple client example with SSH-style certificate verification.
db_name: A file specifying the stored keys (use NULL for the default)
tdb: A storage structure or NULL to use the default
host: The peer’s name
service: non-NULL if this key is specific to a service (e.g. http)
cert_type: The type of the certificate
cert: The raw (der) data of the certificate
flags: should be 0.
This function will try to verify the provided certificate using
a list of stored public keys. The service field if non-NULL should
be a port number.
The retrieve variable if non-null specifies a custom backend for
the retrieval of entries. If it is NULL then the
default file backend will be used. In POSIX-like systems the
file backend uses the $HOME/.gnutls/known_hosts file.
Note that if the custom storage backend is provided the
retrieval function should return GNUTLS_E_CERTIFICATE_KEY_MISMATCH
if the host/service pair is found but key doesn’t match,
GNUTLS_E_NO_CERTIFICATE_FOUND if no such host/service with
the given key is found, and 0 if it was found. The storage
function should return 0 on success.
Returns: If no associated public key is found
then GNUTLS_E_NO_CERTIFICATE_FOUND will be returned. If a key
is found but does not match GNUTLS_E_CERTIFICATE_KEY_MISMATCH
is returned. On success, GNUTLS_E_SUCCESS (0) is returned,
or a negative error value on other errors.
Since: 3.0
db_name: A file specifying the stored keys (use NULL for the default)
tdb: A storage structure or NULL to use the default
host: The peer’s name
service: non-NULL if this key is specific to a service (e.g. http)
cert_type: The type of the certificate
cert: The data of the certificate
expiration: The expiration time (use 0 to disable expiration)
flags: should be 0.
This function will store the provided certificate to the list of stored public keys. The key will be considered valid until the provided expiration time.
The store variable if non-null specifies a custom backend for
the storage of entries. If it is NULL then the
default file backend will be used.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 3.0
In addition to the above the gnutls_store_commitment can be used to implement a key-pinning architecture as in [KEYPIN]. This provides a way for web server to commit on a public key that is not yet active.
db_name: A file specifying the stored keys (use NULL for the default)
tdb: A storage structure or NULL to use the default
host: The peer’s name
service: non-NULL if this key is specific to a service (e.g. http)
hash_algo: The hash algorithm type
hash: The raw hash
expiration: The expiration time (use 0 to disable expiration)
flags: should be 0.
This function will store the provided hash commitment to the list of stored public keys. The key with the given hash will be considered valid until the provided expiration time.
The store variable if non-null specifies a custom backend for
the storage of entries. If it is NULL then the
default file backend will be used.
Note that this function is not thread safe with the default backend.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 3.0
The storage and verification functions may be used with the default text file based back-end, or another back-end may be specified. That should contain storage and retrieval functions and specified as below.
gnutls_tdb_initgnutls_tdb_deinitgnutls_tdb_set_verify_funcgnutls_tdb_set_store_funcgnutls_tdb_set_store_commitment_funcPrevious: Verifying a certificate in the context of TLS session, Up: X.509 certificates [Contents][Index]