summaryrefslogtreecommitdiff
path: root/src/lib/libssl/doc/SSL_CTX_set_client_cert_cb.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/doc/SSL_CTX_set_client_cert_cb.3')
-rw-r--r--src/lib/libssl/doc/SSL_CTX_set_client_cert_cb.3140
1 files changed, 140 insertions, 0 deletions
diff --git a/src/lib/libssl/doc/SSL_CTX_set_client_cert_cb.3 b/src/lib/libssl/doc/SSL_CTX_set_client_cert_cb.3
new file mode 100644
index 0000000000..6aaa5f1016
--- /dev/null
+++ b/src/lib/libssl/doc/SSL_CTX_set_client_cert_cb.3
@@ -0,0 +1,140 @@
1.Dd $Mdocdate: October 12 2014 $
2.Dt SSL_CTX_SET_CLIENT_CERT_CB 3
3.Os
4.Sh NAME
5.Nm SSL_CTX_set_client_cert_cb ,
6.Nm SSL_CTX_get_client_cert_cb
7.Nd handle client certificate callback function
8.Sh SYNOPSIS
9.In openssl/ssl.h
10.Ft void
11.Fo SSL_CTX_set_client_cert_cb
12.Fa "SSL_CTX *ctx"
13.Fa "int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)"
14.Fc
15.Ft int
16.Fo "(*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))"
17.Fa "SSL *ssl" "X509 **x509" "EVP_PKEY **pkey"
18.Fc
19.Ft int
20.Fn "(*client_cert_cb)" "SSL *ssl" "X509 **x509" "EVP_PKEY **pkey"
21.Sh DESCRIPTION
22.Fn SSL_CTX_set_client_cert_cb
23sets the
24.Fa client_cert_cb()
25callback that is called when a client certificate is requested by a server and
26no certificate was yet set for the SSL object.
27.Pp
28When
29.Fa client_cert_cb
30is
31.Dv NULL ,
32no callback function is used.
33.Pp
34.Fn SSL_CTX_get_client_cert_cb
35returns a pointer to the currently set callback function.
36.Pp
37.Fn client_cert_cb
38is the application-defined callback.
39If it wants to set a certificate,
40a certificate/private key combination must be set using the
41.Fa x509
42and
43.Fa pkey
44arguments and 1 must be returned.
45The certificate will be installed into
46.Fa ssl ;
47see the
48.Sx NOTES
49and
50.Sx BUGS
51sections.
52If no certificate should be set,
530 has to be returned and no certificate will be sent.
54A negative return value will suspend the handshake and the handshake function
55will return immediately.
56.Xr SSL_get_error 3
57will return
58.Dv SSL_ERROR_WANT_X509_LOOKUP
59to indicate that the handshake was suspended.
60The next call to the handshake function will again lead to the call of
61.Fa client_cert_cb() .
62It is the job of the
63.Fa client_cert_cb()
64to store information
65about the state of the last call, if required to continue.
66.Sh NOTES
67During a handshake (or renegotiation)
68a server may request a certificate from the client.
69A client certificate must only be sent when the server did send the request.
70.Pp
71When a certificate has been set using the
72.Xr SSL_CTX_use_certificate 3
73family of functions,
74it will be sent to the server.
75The TLS standard requires that only a certificate is sent if it matches the
76list of acceptable CAs sent by the server.
77This constraint is violated by the default behavior of the OpenSSL library.
78Using the callback function it is possible to implement a proper selection
79routine or to allow a user interaction to choose the certificate to be sent.
80.Pp
81If a callback function is defined and no certificate was yet defined for the
82.Vt SSL
83object, the callback function will be called.
84If the callback function returns a certificate, the OpenSSL library
85will try to load the private key and certificate data into the
86.Vt SSL
87object using the
88.Fn SSL_use_certificate
89and
90.Fn SSL_use_private_key
91functions.
92Thus it will permanently install the certificate and key for this SSL object.
93It will not be reset by calling
94.Xr SSL_clear 3 .
95If the callback returns no certificate, the OpenSSL library will not send a
96certificate.
97.Sh SEE ALSO
98.Xr ssl 3 ,
99.Xr SSL_clear 3 ,
100.Xr SSL_CTX_add_extra_chain_cert 3 ,
101.Xr SSL_CTX_use_certificate 3 ,
102.Xr SSL_free 3 ,
103.Xr SSL_get_client_CA_list 3
104.Sh BUGS
105The
106.Fa client_cert_cb()
107cannot return a complete certificate chain;
108it can only return one client certificate.
109If the chain only has a length of 2,
110the root CA certificate may be omitted according to the TLS standard and
111thus a standard conforming answer can be sent to the server.
112For a longer chain, the client must send the complete chain
113(with the option to leave out the root CA certificate).
114This can be accomplished only by either adding the intermediate CA certificates
115into the trusted certificate store for the
116.Vt SSL_CTX
117object (resulting in having to add CA certificates that otherwise maybe would
118not be trusted), or by adding the chain certificates using the
119.Xr SSL_CTX_add_extra_chain_cert 3
120function, which is only available for the
121.Vt SSL_CTX
122object as a whole and that therefore probably can only apply for one client
123certificate, making the concept of the callback function
124(to allow the choice from several certificates) questionable.
125.Pp
126Once the
127.Vt SSL
128object has been used in conjunction with the callback function,
129the certificate will be set for the
130.Vt SSL
131object and will not be cleared even when
132.Xr SSL_clear 3
133is called.
134It is therefore
135.Em mandatory
136to destroy the
137.Vt SSL
138object using
139.Xr SSL_free 3
140and create a new one to return to the previous state.