xref: /freebsd/crypto/openssl/doc/man3/SSL_CTX_dane_enable.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimSSL_CTX_dane_enable, SSL_CTX_dane_mtype_set, SSL_dane_enable,
6e71b7053SJung-uk KimSSL_dane_tlsa_add, SSL_get0_dane_authority, SSL_get0_dane_tlsa,
7e71b7053SJung-uk KimSSL_CTX_dane_set_flags, SSL_CTX_dane_clear_flags,
8e71b7053SJung-uk KimSSL_dane_set_flags, SSL_dane_clear_flags
9e71b7053SJung-uk Kim- enable DANE TLS authentication of the remote TLS server in the local
10e71b7053SJung-uk KimTLS client
11e71b7053SJung-uk Kim
12e71b7053SJung-uk Kim=head1 SYNOPSIS
13e71b7053SJung-uk Kim
14e71b7053SJung-uk Kim #include <openssl/ssl.h>
15e71b7053SJung-uk Kim
16e71b7053SJung-uk Kim int SSL_CTX_dane_enable(SSL_CTX *ctx);
17e71b7053SJung-uk Kim int SSL_CTX_dane_mtype_set(SSL_CTX *ctx, const EVP_MD *md,
18e71b7053SJung-uk Kim                            uint8_t mtype, uint8_t ord);
19e71b7053SJung-uk Kim int SSL_dane_enable(SSL *s, const char *basedomain);
20e71b7053SJung-uk Kim int SSL_dane_tlsa_add(SSL *s, uint8_t usage, uint8_t selector,
21*b077aed3SPierre Pronchery                       uint8_t mtype, const unsigned char *data, size_t dlen);
22e71b7053SJung-uk Kim int SSL_get0_dane_authority(SSL *s, X509 **mcert, EVP_PKEY **mspki);
23e71b7053SJung-uk Kim int SSL_get0_dane_tlsa(SSL *s, uint8_t *usage, uint8_t *selector,
24*b077aed3SPierre Pronchery                        uint8_t *mtype, const unsigned char **data,
25e71b7053SJung-uk Kim                        size_t *dlen);
26e71b7053SJung-uk Kim unsigned long SSL_CTX_dane_set_flags(SSL_CTX *ctx, unsigned long flags);
27e71b7053SJung-uk Kim unsigned long SSL_CTX_dane_clear_flags(SSL_CTX *ctx, unsigned long flags);
28e71b7053SJung-uk Kim unsigned long SSL_dane_set_flags(SSL *ssl, unsigned long flags);
29e71b7053SJung-uk Kim unsigned long SSL_dane_clear_flags(SSL *ssl, unsigned long flags);
30e71b7053SJung-uk Kim
31e71b7053SJung-uk Kim=head1 DESCRIPTION
32e71b7053SJung-uk Kim
33e71b7053SJung-uk KimThese functions implement support for DANE TLSA (RFC6698 and RFC7671)
34e71b7053SJung-uk Kimpeer authentication.
35e71b7053SJung-uk Kim
36e71b7053SJung-uk KimSSL_CTX_dane_enable() must be called first to initialize the shared state
37e71b7053SJung-uk Kimrequired for DANE support.
38e71b7053SJung-uk KimIndividual connections associated with the context can then enable
39e71b7053SJung-uk Kimper-connection DANE support as appropriate.
40e71b7053SJung-uk KimDANE authentication is implemented in the L<X509_verify_cert(3)> function, and
41e71b7053SJung-uk Kimapplications that override L<X509_verify_cert(3)> via
42e71b7053SJung-uk KimL<SSL_CTX_set_cert_verify_callback(3)> are responsible to authenticate the peer
43e71b7053SJung-uk Kimchain in whatever manner they see fit.
44e71b7053SJung-uk Kim
45e71b7053SJung-uk KimSSL_CTX_dane_mtype_set() may then be called zero or more times to adjust the
46e71b7053SJung-uk Kimsupported digest algorithms.
47e71b7053SJung-uk KimThis must be done before any SSL handles are created for the context.
48e71b7053SJung-uk Kim
49e71b7053SJung-uk KimThe B<mtype> argument specifies a DANE TLSA matching type and the B<md>
50e71b7053SJung-uk Kimargument specifies the associated digest algorithm handle.
51e71b7053SJung-uk KimThe B<ord> argument specifies a strength ordinal.
52e71b7053SJung-uk KimAlgorithms with a larger strength ordinal are considered more secure.
53e71b7053SJung-uk KimStrength ordinals are used to implement RFC7671 digest algorithm agility.
54e71b7053SJung-uk KimSpecifying a B<NULL> digest algorithm for a matching type disables
55e71b7053SJung-uk Kimsupport for that matching type.
56e71b7053SJung-uk KimMatching type Full(0) cannot be modified or disabled.
57e71b7053SJung-uk Kim
58e71b7053SJung-uk KimBy default, matching type C<SHA2-256(1)> (see RFC7218 for definitions
59e71b7053SJung-uk Kimof the DANE TLSA parameter acronyms) is mapped to C<EVP_sha256()>
60e71b7053SJung-uk Kimwith a strength ordinal of C<1> and matching type C<SHA2-512(2)>
61e71b7053SJung-uk Kimis mapped to C<EVP_sha512()> with a strength ordinal of C<2>.
62e71b7053SJung-uk Kim
63e71b7053SJung-uk KimSSL_dane_enable() must be called before the SSL handshake is initiated with
64e71b7053SJung-uk KimL<SSL_connect(3)> if (and only if) you want to enable DANE for that connection.
65e71b7053SJung-uk Kim(The connection must be associated with a DANE-enabled SSL context).
66e71b7053SJung-uk KimThe B<basedomain> argument specifies the RFC7671 TLSA base domain,
67e71b7053SJung-uk Kimwhich will be the primary peer reference identifier for certificate
68e71b7053SJung-uk Kimname checks.
69e71b7053SJung-uk KimAdditional server names can be specified via L<SSL_add1_host(3)>.
70e71b7053SJung-uk KimThe B<basedomain> is used as the default SNI hint if none has yet been
71e71b7053SJung-uk Kimspecified via L<SSL_set_tlsext_host_name(3)>.
72e71b7053SJung-uk Kim
73e71b7053SJung-uk KimSSL_dane_tlsa_add() may then be called one or more times, to load each of the
74e71b7053SJung-uk KimTLSA records that apply to the remote TLS peer.
75e71b7053SJung-uk Kim(This too must be done prior to the beginning of the SSL handshake).
76e71b7053SJung-uk KimThe arguments specify the fields of the TLSA record.
77e71b7053SJung-uk KimThe B<data> field is provided in binary (wire RDATA) form, not the hexadecimal
78e71b7053SJung-uk KimASCII presentation form, with an explicit length passed via B<dlen>.
79e71b7053SJung-uk KimThe library takes a copy of the B<data> buffer contents and the caller may
80e71b7053SJung-uk Kimfree the original B<data> buffer when convenient.
81e71b7053SJung-uk KimA return value of 0 indicates that "unusable" TLSA records (with invalid or
82e71b7053SJung-uk Kimunsupported parameters) were provided.
83e71b7053SJung-uk KimA negative return value indicates an internal error in processing the record.
84e71b7053SJung-uk Kim
85e71b7053SJung-uk KimThe caller is expected to check the return value of each SSL_dane_tlsa_add()
86e71b7053SJung-uk Kimcall and take appropriate action if none are usable or an internal error
87e71b7053SJung-uk Kimis encountered in processing some records.
88e71b7053SJung-uk Kim
89e71b7053SJung-uk KimIf no TLSA records are added successfully, DANE authentication is not enabled,
90e71b7053SJung-uk Kimand authentication will be based on any configured traditional trust-anchors;
91e71b7053SJung-uk Kimauthentication success in this case does not mean that the peer was
92e71b7053SJung-uk KimDANE-authenticated.
93e71b7053SJung-uk Kim
94e71b7053SJung-uk KimSSL_get0_dane_authority() can be used to get more detailed information about
95e71b7053SJung-uk Kimthe matched DANE trust-anchor after successful connection completion.
96e71b7053SJung-uk KimThe return value is negative if DANE verification failed (or was not enabled),
97e71b7053SJung-uk Kim0 if an EE TLSA record directly matched the leaf certificate, or a positive
98e71b7053SJung-uk Kimnumber indicating the depth at which a TA record matched an issuer certificate.
99e71b7053SJung-uk KimThe complete verified chain can be retrieved via L<SSL_get0_verified_chain(3)>.
100e71b7053SJung-uk KimThe return value is an index into this verified chain, rather than the list of
101e71b7053SJung-uk Kimcertificates sent by the peer as returned by L<SSL_get_peer_cert_chain(3)>.
102e71b7053SJung-uk Kim
103e71b7053SJung-uk KimIf the B<mcert> argument is not B<NULL> and a TLSA record matched a chain
104e71b7053SJung-uk Kimcertificate, a pointer to the matching certificate is returned via B<mcert>.
105e71b7053SJung-uk KimThe returned address is a short-term internal reference to the certificate and
106e71b7053SJung-uk Kimmust not be freed by the application.
107e71b7053SJung-uk KimApplications that want to retain access to the certificate can call
108e71b7053SJung-uk KimL<X509_up_ref(3)> to obtain a long-term reference which must then be freed via
109e71b7053SJung-uk KimL<X509_free(3)> once no longer needed.
110e71b7053SJung-uk Kim
111e71b7053SJung-uk KimIf no TLSA records directly matched any elements of the certificate chain, but
112e71b7053SJung-uk Kima DANE-TA(2) SPKI(1) Full(0) record provided the public key that signed an
113e71b7053SJung-uk Kimelement of the chain, then that key is returned via B<mspki> argument (if not
114e71b7053SJung-uk KimNULL).
115e71b7053SJung-uk KimIn this case the return value is the depth of the top-most element of the
116e71b7053SJung-uk Kimvalidated certificate chain.
117e71b7053SJung-uk KimAs with B<mcert> this is a short-term internal reference, and
118e71b7053SJung-uk KimL<EVP_PKEY_up_ref(3)> and L<EVP_PKEY_free(3)> can be used to acquire and
119e71b7053SJung-uk Kimrelease long-term references respectively.
120e71b7053SJung-uk Kim
121e71b7053SJung-uk KimSSL_get0_dane_tlsa() can be used to retrieve the fields of the TLSA record that
122e71b7053SJung-uk Kimmatched the peer certificate chain.
123e71b7053SJung-uk KimThe return value indicates the match depth or failure to match just as with
124e71b7053SJung-uk KimSSL_get0_dane_authority().
12558f35182SJung-uk KimWhen the return value is nonnegative, the storage pointed to by the B<usage>,
126e71b7053SJung-uk KimB<selector>, B<mtype> and B<data> parameters is updated to the corresponding
127e71b7053SJung-uk KimTLSA record fields.
128e71b7053SJung-uk KimThe B<data> field is in binary wire form, and is therefore not NUL-terminated,
129e71b7053SJung-uk Kimits length is returned via the B<dlen> parameter.
130e71b7053SJung-uk KimIf any of these parameters is NULL, the corresponding field is not returned.
131e71b7053SJung-uk KimThe B<data> parameter is set to a short-term internal-copy of the associated
132e71b7053SJung-uk Kimdata field and must not be freed by the application.
133e71b7053SJung-uk KimApplications that need long-term access to this field need to copy the content.
134e71b7053SJung-uk Kim
135e71b7053SJung-uk KimSSL_CTX_dane_set_flags() and SSL_dane_set_flags() can be used to enable
136e71b7053SJung-uk Kimoptional DANE verification features.
137e71b7053SJung-uk KimSSL_CTX_dane_clear_flags() and SSL_dane_clear_flags() can be used to disable
138e71b7053SJung-uk Kimthe same features.
139*b077aed3SPierre ProncheryThe B<flags> argument is a bit-mask of the features to enable or disable.
140e71b7053SJung-uk KimThe B<flags> set for an B<SSL_CTX> context are copied to each B<SSL> handle
141e71b7053SJung-uk Kimassociated with that context at the time the handle is created.
142e71b7053SJung-uk KimSubsequent changes in the context's B<flags> have no effect on the B<flags> set
143e71b7053SJung-uk Kimfor the handle.
144e71b7053SJung-uk Kim
145e71b7053SJung-uk KimAt present, the only available option is B<DANE_FLAG_NO_DANE_EE_NAMECHECKS>
146e71b7053SJung-uk Kimwhich can be used to disable server name checks when authenticating via
147e71b7053SJung-uk KimDANE-EE(3) TLSA records.
148e71b7053SJung-uk KimFor some applications, primarily web browsers, it is not safe to disable name
149e71b7053SJung-uk Kimchecks due to "unknown key share" attacks, in which a malicious server can
150e71b7053SJung-uk Kimconvince a client that a connection to a victim server is instead a secure
151e71b7053SJung-uk Kimconnection to the malicious server.
152e71b7053SJung-uk KimThe malicious server may then be able to violate cross-origin scripting
153e71b7053SJung-uk Kimrestrictions.
154e71b7053SJung-uk KimThus, despite the text of RFC7671, name checks are by default enabled for
155e71b7053SJung-uk KimDANE-EE(3) TLSA records, and can be disabled in applications where it is safe
156e71b7053SJung-uk Kimto do so.
157e71b7053SJung-uk KimIn particular, SMTP and XMPP clients should set this option as SRV and MX
158e71b7053SJung-uk Kimrecords already make it possible for a remote domain to redirect client
159e71b7053SJung-uk Kimconnections to any server of its choice, and in any case SMTP and XMPP clients
160e71b7053SJung-uk Kimdo not execute scripts downloaded from remote servers.
161e71b7053SJung-uk Kim
162e71b7053SJung-uk Kim=head1 RETURN VALUES
163e71b7053SJung-uk Kim
164e71b7053SJung-uk KimThe functions SSL_CTX_dane_enable(), SSL_CTX_dane_mtype_set(),
165e71b7053SJung-uk KimSSL_dane_enable() and SSL_dane_tlsa_add() return a positive value on success.
166e71b7053SJung-uk KimNegative return values indicate resource problems (out of memory, etc.) in the
167e71b7053SJung-uk KimSSL library, while a return value of B<0> indicates incorrect usage or invalid
168e71b7053SJung-uk Kiminput, such as an unsupported TLSA record certificate usage, selector or
169e71b7053SJung-uk Kimmatching type.
170e71b7053SJung-uk KimInvalid input also includes malformed data, either a digest length that does
171e71b7053SJung-uk Kimnot match the digest algorithm, or a C<Full(0)> (binary ASN.1 DER form)
172e71b7053SJung-uk Kimcertificate or a public key that fails to parse.
173e71b7053SJung-uk Kim
174e71b7053SJung-uk KimThe functions SSL_get0_dane_authority() and SSL_get0_dane_tlsa() return a
175e71b7053SJung-uk Kimnegative value when DANE authentication failed or was not enabled, a
17658f35182SJung-uk Kimnonnegative value indicates the chain depth at which the TLSA record matched a
177e71b7053SJung-uk Kimchain certificate, or the depth of the top-most certificate, when the TLSA
178e71b7053SJung-uk Kimrecord is a full public key that is its signer.
179e71b7053SJung-uk Kim
180e71b7053SJung-uk KimThe functions SSL_CTX_dane_set_flags(), SSL_CTX_dane_clear_flags(),
181e71b7053SJung-uk KimSSL_dane_set_flags() and SSL_dane_clear_flags() return the B<flags> in effect
182e71b7053SJung-uk Kimbefore they were called.
183e71b7053SJung-uk Kim
184da327cd2SJung-uk Kim=head1 EXAMPLES
185e71b7053SJung-uk Kim
186e71b7053SJung-uk KimSuppose "smtp.example.com" is the MX host of the domain "example.com", and has
187e71b7053SJung-uk KimDNSSEC-validated TLSA records.
188e71b7053SJung-uk KimThe calls below will perform DANE authentication and arrange to match either
189e71b7053SJung-uk Kimthe MX hostname or the destination domain name in the SMTP server certificate.
190e71b7053SJung-uk KimWildcards are supported, but must match the entire label.
191e71b7053SJung-uk KimThe actual name matched in the certificate (which might be a wildcard) is
192e71b7053SJung-uk Kimretrieved, and must be copied by the application if it is to be retained beyond
193e71b7053SJung-uk Kimthe lifetime of the SSL connection.
194e71b7053SJung-uk Kim
195e71b7053SJung-uk Kim SSL_CTX *ctx;
196e71b7053SJung-uk Kim SSL *ssl;
197e71b7053SJung-uk Kim int (*verify_cb)(int ok, X509_STORE_CTX *sctx) = NULL;
198e71b7053SJung-uk Kim int num_usable = 0;
199e71b7053SJung-uk Kim const char *nexthop_domain = "example.com";
200e71b7053SJung-uk Kim const char *dane_tlsa_domain = "smtp.example.com";
201e71b7053SJung-uk Kim uint8_t usage, selector, mtype;
202e71b7053SJung-uk Kim
203e71b7053SJung-uk Kim if ((ctx = SSL_CTX_new(TLS_client_method())) == NULL)
204e71b7053SJung-uk Kim     /* error */
205e71b7053SJung-uk Kim if (SSL_CTX_dane_enable(ctx) <= 0)
206e71b7053SJung-uk Kim     /* error */
207e71b7053SJung-uk Kim if ((ssl = SSL_new(ctx)) == NULL)
208e71b7053SJung-uk Kim     /* error */
209e71b7053SJung-uk Kim if (SSL_dane_enable(ssl, dane_tlsa_domain) <= 0)
210e71b7053SJung-uk Kim     /* error */
211e71b7053SJung-uk Kim
212e71b7053SJung-uk Kim /*
213e71b7053SJung-uk Kim  * For many applications it is safe to skip DANE-EE(3) namechecks.  Do not
214e71b7053SJung-uk Kim  * disable the checks unless "unknown key share" attacks pose no risk for
215e71b7053SJung-uk Kim  * your application.
216e71b7053SJung-uk Kim  */
217e71b7053SJung-uk Kim SSL_dane_set_flags(ssl, DANE_FLAG_NO_DANE_EE_NAMECHECKS);
218e71b7053SJung-uk Kim
219e71b7053SJung-uk Kim if (!SSL_add1_host(ssl, nexthop_domain))
220e71b7053SJung-uk Kim     /* error */
221e71b7053SJung-uk Kim SSL_set_hostflags(ssl, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
222e71b7053SJung-uk Kim
223e71b7053SJung-uk Kim for (... each TLSA record ...) {
224e71b7053SJung-uk Kim     unsigned char *data;
225e71b7053SJung-uk Kim     size_t len;
226e71b7053SJung-uk Kim     int ret;
227e71b7053SJung-uk Kim
228e71b7053SJung-uk Kim     /* set usage, selector, mtype, data, len */
229e71b7053SJung-uk Kim
230e71b7053SJung-uk Kim     /*
231e71b7053SJung-uk Kim      * Opportunistic DANE TLS clients support only DANE-TA(2) or DANE-EE(3).
232e71b7053SJung-uk Kim      * They treat all other certificate usages, and in particular PKIX-TA(0)
233e71b7053SJung-uk Kim      * and PKIX-EE(1), as unusable.
234e71b7053SJung-uk Kim      */
235e71b7053SJung-uk Kim     switch (usage) {
236e71b7053SJung-uk Kim     default:
237e71b7053SJung-uk Kim     case 0:     /* PKIX-TA(0) */
238e71b7053SJung-uk Kim     case 1:     /* PKIX-EE(1) */
239e71b7053SJung-uk Kim         continue;
240e71b7053SJung-uk Kim     case 2:     /* DANE-TA(2) */
241e71b7053SJung-uk Kim     case 3:     /* DANE-EE(3) */
242e71b7053SJung-uk Kim         break;
243e71b7053SJung-uk Kim     }
244e71b7053SJung-uk Kim
245e71b7053SJung-uk Kim     ret = SSL_dane_tlsa_add(ssl, usage, selector, mtype, data, len);
246e71b7053SJung-uk Kim     /* free data as appropriate */
247e71b7053SJung-uk Kim
248e71b7053SJung-uk Kim     if (ret < 0)
249e71b7053SJung-uk Kim         /* handle SSL library internal error */
250e71b7053SJung-uk Kim     else if (ret == 0)
251e71b7053SJung-uk Kim         /* handle unusable TLSA record */
252e71b7053SJung-uk Kim     else
253e71b7053SJung-uk Kim         ++num_usable;
254e71b7053SJung-uk Kim }
255e71b7053SJung-uk Kim
256e71b7053SJung-uk Kim /*
257e71b7053SJung-uk Kim  * At this point, the verification mode is still the default SSL_VERIFY_NONE.
258e71b7053SJung-uk Kim  * Opportunistic DANE clients use unauthenticated TLS when all TLSA records
259e71b7053SJung-uk Kim  * are unusable, so continue the handshake even if authentication fails.
260e71b7053SJung-uk Kim  */
261e71b7053SJung-uk Kim if (num_usable == 0) {
262e71b7053SJung-uk Kim     /* Log all records unusable? */
263e71b7053SJung-uk Kim
264e71b7053SJung-uk Kim     /* Optionally set verify_cb to a suitable non-NULL callback. */
265e71b7053SJung-uk Kim     SSL_set_verify(ssl, SSL_VERIFY_NONE, verify_cb);
266e71b7053SJung-uk Kim } else {
267e71b7053SJung-uk Kim     /* At least one usable record.  We expect to verify the peer */
268e71b7053SJung-uk Kim
269e71b7053SJung-uk Kim     /* Optionally set verify_cb to a suitable non-NULL callback. */
270e71b7053SJung-uk Kim
271e71b7053SJung-uk Kim     /*
272e71b7053SJung-uk Kim      * Below we elect to fail the handshake when peer verification fails.
273e71b7053SJung-uk Kim      * Alternatively, use the permissive SSL_VERIFY_NONE verification mode,
274e71b7053SJung-uk Kim      * complete the handshake, check the verification status, and if not
275e71b7053SJung-uk Kim      * verified disconnect gracefully at the application layer, especially if
276e71b7053SJung-uk Kim      * application protocol supports informing the server that authentication
277e71b7053SJung-uk Kim      * failed.
278e71b7053SJung-uk Kim      */
279e71b7053SJung-uk Kim     SSL_set_verify(ssl, SSL_VERIFY_PEER, verify_cb);
280e71b7053SJung-uk Kim }
281e71b7053SJung-uk Kim
282e71b7053SJung-uk Kim /*
283e71b7053SJung-uk Kim  * Load any saved session for resumption, making sure that the previous
284e71b7053SJung-uk Kim  * session applied the same security and authentication requirements that
285e71b7053SJung-uk Kim  * would be expected of a fresh connection.
286e71b7053SJung-uk Kim  */
287e71b7053SJung-uk Kim
288e71b7053SJung-uk Kim /* Perform SSL_connect() handshake and handle errors here */
289e71b7053SJung-uk Kim
290e71b7053SJung-uk Kim if (SSL_session_reused(ssl)) {
291e71b7053SJung-uk Kim     if (SSL_get_verify_result(ssl) == X509_V_OK) {
292e71b7053SJung-uk Kim         /*
293e71b7053SJung-uk Kim          * Resumed session was originally verified, this connection is
294e71b7053SJung-uk Kim          * authenticated.
295e71b7053SJung-uk Kim          */
296e71b7053SJung-uk Kim     } else {
297e71b7053SJung-uk Kim         /*
298e71b7053SJung-uk Kim          * Resumed session was not originally verified, this connection is not
299e71b7053SJung-uk Kim          * authenticated.
300e71b7053SJung-uk Kim          */
301e71b7053SJung-uk Kim     }
302e71b7053SJung-uk Kim } else if (SSL_get_verify_result(ssl) == X509_V_OK) {
303e71b7053SJung-uk Kim     const char *peername = SSL_get0_peername(ssl);
304e71b7053SJung-uk Kim     EVP_PKEY *mspki = NULL;
305e71b7053SJung-uk Kim
306e71b7053SJung-uk Kim     int depth = SSL_get0_dane_authority(ssl, NULL, &mspki);
307e71b7053SJung-uk Kim     if (depth >= 0) {
308e71b7053SJung-uk Kim         (void) SSL_get0_dane_tlsa(ssl, &usage, &selector, &mtype, NULL, NULL);
309e71b7053SJung-uk Kim         printf("DANE TLSA %d %d %d %s at depth %d\n", usage, selector, mtype,
310e71b7053SJung-uk Kim                (mspki != NULL) ? "TA public key verified certificate" :
311e71b7053SJung-uk Kim                depth ? "matched TA certificate" : "matched EE certificate",
312e71b7053SJung-uk Kim                depth);
313e71b7053SJung-uk Kim     }
314e71b7053SJung-uk Kim     if (peername != NULL) {
315e71b7053SJung-uk Kim         /* Name checks were in scope and matched the peername */
316e71b7053SJung-uk Kim         printf("Verified peername: %s\n", peername);
317e71b7053SJung-uk Kim     }
318e71b7053SJung-uk Kim } else {
319e71b7053SJung-uk Kim     /*
320e71b7053SJung-uk Kim      * Not authenticated, presumably all TLSA rrs unusable, but possibly a
321e71b7053SJung-uk Kim      * callback suppressed connection termination despite the presence of
322e71b7053SJung-uk Kim      * usable TLSA RRs none of which matched.  Do whatever is appropriate for
323e71b7053SJung-uk Kim      * fresh unauthenticated connections.
324e71b7053SJung-uk Kim      */
325e71b7053SJung-uk Kim }
326e71b7053SJung-uk Kim
327e71b7053SJung-uk Kim=head1 NOTES
328e71b7053SJung-uk Kim
329e71b7053SJung-uk KimIt is expected that the majority of clients employing DANE TLS will be doing
330e71b7053SJung-uk Kim"opportunistic DANE TLS" in the sense of RFC7672 and RFC7435.
331e71b7053SJung-uk KimThat is, they will use DANE authentication when DNSSEC-validated TLSA records
332e71b7053SJung-uk Kimare published for a given peer, and otherwise will use unauthenticated TLS or
333e71b7053SJung-uk Kimeven cleartext.
334e71b7053SJung-uk Kim
335e71b7053SJung-uk KimSuch applications should generally treat any TLSA records published by the peer
336e71b7053SJung-uk Kimwith usages PKIX-TA(0) and PKIX-EE(1) as "unusable", and should not include
337e71b7053SJung-uk Kimthem among the TLSA records used to authenticate peer connections.
338e71b7053SJung-uk KimIn addition, some TLSA records with supported usages may be "unusable" as a
339e71b7053SJung-uk Kimresult of invalid or unsupported parameters.
340e71b7053SJung-uk Kim
341e71b7053SJung-uk KimWhen a peer has TLSA records, but none are "usable", an opportunistic
342e71b7053SJung-uk Kimapplication must avoid cleartext, but cannot authenticate the peer,
343e71b7053SJung-uk Kimand so should generally proceed with an unauthenticated connection.
344e71b7053SJung-uk KimOpportunistic applications need to note the return value of each
345e71b7053SJung-uk Kimcall to SSL_dane_tlsa_add(), and if all return 0 (due to invalid
346e71b7053SJung-uk Kimor unsupported parameters) disable peer authentication by calling
347e71b7053SJung-uk KimL<SSL_set_verify(3)> with B<mode> equal to B<SSL_VERIFY_NONE>.
348e71b7053SJung-uk Kim
349e71b7053SJung-uk Kim=head1 SEE ALSO
350e71b7053SJung-uk Kim
351*b077aed3SPierre ProncheryL<ssl(7)>,
352e71b7053SJung-uk KimL<SSL_new(3)>,
353e71b7053SJung-uk KimL<SSL_add1_host(3)>,
354e71b7053SJung-uk KimL<SSL_set_hostflags(3)>,
355e71b7053SJung-uk KimL<SSL_set_tlsext_host_name(3)>,
356e71b7053SJung-uk KimL<SSL_set_verify(3)>,
357e71b7053SJung-uk KimL<SSL_CTX_set_cert_verify_callback(3)>,
358e71b7053SJung-uk KimL<SSL_get0_verified_chain(3)>,
359e71b7053SJung-uk KimL<SSL_get_peer_cert_chain(3)>,
360e71b7053SJung-uk KimL<SSL_get_verify_result(3)>,
361e71b7053SJung-uk KimL<SSL_connect(3)>,
362e71b7053SJung-uk KimL<SSL_get0_peername(3)>,
363e71b7053SJung-uk KimL<X509_verify_cert(3)>,
364e71b7053SJung-uk KimL<X509_up_ref(3)>,
365e71b7053SJung-uk KimL<X509_free(3)>,
366e71b7053SJung-uk KimL<EVP_get_digestbyname(3)>,
367e71b7053SJung-uk KimL<EVP_PKEY_up_ref(3)>,
368e71b7053SJung-uk KimL<EVP_PKEY_free(3)>
369e71b7053SJung-uk Kim
370e71b7053SJung-uk Kim=head1 HISTORY
371e71b7053SJung-uk Kim
3726935a639SJung-uk KimThese functions were added in OpenSSL 1.1.0.
373e71b7053SJung-uk Kim
374e71b7053SJung-uk Kim=head1 COPYRIGHT
375e71b7053SJung-uk Kim
376*b077aed3SPierre ProncheryCopyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
377e71b7053SJung-uk Kim
378*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
379e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
380e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
381e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
382e71b7053SJung-uk Kim
383e71b7053SJung-uk Kim=cut
384