diff options
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.3 | 140 |
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 | ||
| 23 | sets the | ||
| 24 | .Fa client_cert_cb() | ||
| 25 | callback that is called when a client certificate is requested by a server and | ||
| 26 | no certificate was yet set for the SSL object. | ||
| 27 | .Pp | ||
| 28 | When | ||
| 29 | .Fa client_cert_cb | ||
| 30 | is | ||
| 31 | .Dv NULL , | ||
| 32 | no callback function is used. | ||
| 33 | .Pp | ||
| 34 | .Fn SSL_CTX_get_client_cert_cb | ||
| 35 | returns a pointer to the currently set callback function. | ||
| 36 | .Pp | ||
| 37 | .Fn client_cert_cb | ||
| 38 | is the application-defined callback. | ||
| 39 | If it wants to set a certificate, | ||
| 40 | a certificate/private key combination must be set using the | ||
| 41 | .Fa x509 | ||
| 42 | and | ||
| 43 | .Fa pkey | ||
| 44 | arguments and 1 must be returned. | ||
| 45 | The certificate will be installed into | ||
| 46 | .Fa ssl ; | ||
| 47 | see the | ||
| 48 | .Sx NOTES | ||
| 49 | and | ||
| 50 | .Sx BUGS | ||
| 51 | sections. | ||
| 52 | If no certificate should be set, | ||
| 53 | 0 has to be returned and no certificate will be sent. | ||
| 54 | A negative return value will suspend the handshake and the handshake function | ||
| 55 | will return immediately. | ||
| 56 | .Xr SSL_get_error 3 | ||
| 57 | will return | ||
| 58 | .Dv SSL_ERROR_WANT_X509_LOOKUP | ||
| 59 | to indicate that the handshake was suspended. | ||
| 60 | The next call to the handshake function will again lead to the call of | ||
| 61 | .Fa client_cert_cb() . | ||
| 62 | It is the job of the | ||
| 63 | .Fa client_cert_cb() | ||
| 64 | to store information | ||
| 65 | about the state of the last call, if required to continue. | ||
| 66 | .Sh NOTES | ||
| 67 | During a handshake (or renegotiation) | ||
| 68 | a server may request a certificate from the client. | ||
| 69 | A client certificate must only be sent when the server did send the request. | ||
| 70 | .Pp | ||
| 71 | When a certificate has been set using the | ||
| 72 | .Xr SSL_CTX_use_certificate 3 | ||
| 73 | family of functions, | ||
| 74 | it will be sent to the server. | ||
| 75 | The TLS standard requires that only a certificate is sent if it matches the | ||
| 76 | list of acceptable CAs sent by the server. | ||
| 77 | This constraint is violated by the default behavior of the OpenSSL library. | ||
| 78 | Using the callback function it is possible to implement a proper selection | ||
| 79 | routine or to allow a user interaction to choose the certificate to be sent. | ||
| 80 | .Pp | ||
| 81 | If a callback function is defined and no certificate was yet defined for the | ||
| 82 | .Vt SSL | ||
| 83 | object, the callback function will be called. | ||
| 84 | If the callback function returns a certificate, the OpenSSL library | ||
| 85 | will try to load the private key and certificate data into the | ||
| 86 | .Vt SSL | ||
| 87 | object using the | ||
| 88 | .Fn SSL_use_certificate | ||
| 89 | and | ||
| 90 | .Fn SSL_use_private_key | ||
| 91 | functions. | ||
| 92 | Thus it will permanently install the certificate and key for this SSL object. | ||
| 93 | It will not be reset by calling | ||
| 94 | .Xr SSL_clear 3 . | ||
| 95 | If the callback returns no certificate, the OpenSSL library will not send a | ||
| 96 | certificate. | ||
| 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 | ||
| 105 | The | ||
| 106 | .Fa client_cert_cb() | ||
| 107 | cannot return a complete certificate chain; | ||
| 108 | it can only return one client certificate. | ||
| 109 | If the chain only has a length of 2, | ||
| 110 | the root CA certificate may be omitted according to the TLS standard and | ||
| 111 | thus a standard conforming answer can be sent to the server. | ||
| 112 | For a longer chain, the client must send the complete chain | ||
| 113 | (with the option to leave out the root CA certificate). | ||
| 114 | This can be accomplished only by either adding the intermediate CA certificates | ||
| 115 | into the trusted certificate store for the | ||
| 116 | .Vt SSL_CTX | ||
| 117 | object (resulting in having to add CA certificates that otherwise maybe would | ||
| 118 | not be trusted), or by adding the chain certificates using the | ||
| 119 | .Xr SSL_CTX_add_extra_chain_cert 3 | ||
| 120 | function, which is only available for the | ||
| 121 | .Vt SSL_CTX | ||
| 122 | object as a whole and that therefore probably can only apply for one client | ||
| 123 | certificate, making the concept of the callback function | ||
| 124 | (to allow the choice from several certificates) questionable. | ||
| 125 | .Pp | ||
| 126 | Once the | ||
| 127 | .Vt SSL | ||
| 128 | object has been used in conjunction with the callback function, | ||
| 129 | the certificate will be set for the | ||
| 130 | .Vt SSL | ||
| 131 | object and will not be cleared even when | ||
| 132 | .Xr SSL_clear 3 | ||
| 133 | is called. | ||
| 134 | It is therefore | ||
| 135 | .Em mandatory | ||
| 136 | to destroy the | ||
| 137 | .Vt SSL | ||
| 138 | object using | ||
| 139 | .Xr SSL_free 3 | ||
| 140 | and create a new one to return to the previous state. | ||
