nbdkit_peer_tls_dn3
Read the client tls x.509 distinguished name
Usage
#include <nbdkit-plugin.h>char *nbdkit_peer_tls_dn (void);char *nbdkit_peer_tls_issuer_dn (void);
Overview
If all of these conditions are met:
•
|
the client connects over TLS (see nbdkit-tls(1)) |
|---|---|
•
|
the TLS connection is using X.509 certificates |
•
|
the client presents a client certificate |
•
|
the nbdkit --tls-verify-peer option is used |
then these APIs can be used to get the Distinguished Name (DN) of the certificate or the certificate's issuer. The issuer is the Certificate Authority (CA) that issued the client certificate.
The DN is returned as a string of the form "CN=xx,O=yy,[...]C=zz" (see RFC 4514 for the exact format).
If the DN is not available, "" is returned (this is not an error).
nbdkit-ip-filter(1) can be used to filter client connections by the DN.
Example certificate and distinguished name
Please see nbdkit-tls(1) for details of how to generate client certificates. Following those instructions, if you were to generate a client certificate from this client.info input:
country = USstate = New Yorklocality = New Yorkorganization = BigCocn = client.example.comtls_www_clientencryption_keysigning_key
and sign it with this Certificate Authority ca.info:
cn = BigCocacert_signing_key
then the client certificate DN would be:
CN=client.example.com,O=BigCo,L=New York,ST=New York,C=US
and the issuer DN would be:
CN=BigCo
Return value
On success both of these functions return a TLS Distinguished Name as a string, or "". The caller must free this string.
If there is an error they call nbdkit_error(3) and return "NULL".
Language bindings
In nbdkit-ocaml-plugin(3):
NBDKit.peer_tls_dn : unit -> stringNBDKit.peer_tls_issuer_dn : unit -> string
import nbdkitdn = nbdkit.peer_tls_dn()dn = nbdkit.peer_tls_issuer_dn()