doc update
[gnutls.git] / doc / cha-cert-auth.texi
blobc4d2fdd21f8d4cf0e1e64a75faf480da05034d03
1 @node Certificate authentication
2 @chapter Certificate authentication
3 @cindex certificate authentication
5 The most known authentication method of @acronym{TLS} are certificates.
6 The PKIX @xcite{PKIX} public key infrastructure is daily used by anyone
7 using a browser today. @acronym{GnuTLS} supports both 
8 @acronym{X.509} certificates @xcite{PKIX} and @acronym{OpenPGP}
9 certificates using a common API.
11 The key exchange algorithms supported by certificate authentication are
12 shown in @ref{tab:key-exchange}.
14 @float Table,tab:key-exchange
15 @multitable @columnfractions .2 .7
17 @headitem Key exchange @tab Description
19 @item RSA @tab
20 The RSA algorithm is used to encrypt a key and send it to the peer.
21 The certificate must allow the key to be used for encryption.
23 @item RSA_@-EXPORT @tab
24 The RSA algorithm is used to encrypt a key and send it to the peer.
25 In the EXPORT algorithm, the server signs temporary RSA parameters of
26 512 bits --- which are considered weak --- and sends them to the
27 client.
29 @item DHE_@-RSA @tab
30 The RSA algorithm is used to sign ephemeral Diffie-Hellman parameters
31 which are sent to the peer. The key in the certificate must allow the
32 key to be used for signing. Note that key exchange algorithms which
33 use ephemeral Diffie-Hellman parameters, offer perfect forward
34 secrecy. That means that even if the private key used for signing is
35 compromised, it cannot be used to reveal past session data.
37 @item ECDHE_@-RSA @tab
38 The RSA algorithm is used to sign ephemeral elliptic curve Diffie-Hellman 
39 parameters which are sent to the peer. The key in the certificate must allow 
40 the key to be used for signing. It also offers perfect forward
41 secrecy. That means that even if the private key used for signing is
42 compromised, it cannot be used to reveal past session data.
44 @item DHE_@-DSS @tab
45 The DSA algorithm is used to sign ephemeral Diffie-Hellman parameters
46 which are sent to the peer. The certificate must contain DSA
47 parameters to use this key exchange algorithm. DSA is the algorithm
48 of the Digital Signature Standard (DSS).
50 @item ECDHE_@-ECDSA @tab
51 The Elliptic curve DSA algorithm is used to sign ephemeral elliptic
52 curve Diffie-Hellman parameters which are sent to the peer. The 
53 certificate must contain ECDSA parameters (i.e., EC and marked for signing) 
54 to use this key exchange algorithm. 
56 @end multitable
57 @caption{Supported key exchange algorithms.}
58 @end float
60 @menu
61 * X.509 certificates::
62 * OpenPGP certificates::
63 * Advanced certificate verification::
64 * Digital signatures::
65 @end menu
67 @node X.509 certificates
68 @section @acronym{X.509} certificates
69 @cindex X.509 certificates
71 The @acronym{X.509} protocols rely on a hierarchical trust model. In
72 this trust model Certification Authorities (CAs) are used to certify
73 entities.  Usually more than one certification authorities exist, and
74 certification authorities may certify other authorities to issue
75 certificates as well, following a hierarchical model.
77 @float Figure,fig:x509
78 @image{gnutls-x509,7cm}
79 @caption{An example of the X.509 hierarchical trust model.}
80 @end float
82 One needs to trust one or more CAs for his secure communications. In
83 that case only the certificates issued by the trusted authorities are
84 acceptable.  The framework is illustrated on @ref{fig:x509}.
86 @menu
87 * X.509 certificate structure::
88 * Importing an X.509 certificate::
89 * X.509 distinguished names::
90 * X.509 public and private keys::
91 * Verifying X.509 certificate paths::
92 * Verifying a certificate in the context of TLS session::
93 @end menu
95 @node X.509 certificate structure
96 @subsection @acronym{X.509} certificate structure
98 An @acronym{X.509} certificate usually contains information about the
99 certificate holder, the signer, a unique serial number, expiration
100 dates and some other fields @xcite{PKIX} as shown in @ref{tab:x509}.
102 @float Table,tab:x509
103 @multitable @columnfractions .2 .7
105 @headitem Field @tab Description
107 @item version @tab
108 The field that indicates the version of the certificate.
110 @item serialNumber @tab
111 This field holds a unique serial number per certificate.
113 @item signature @tab
114 The issuing authority's signature.
116 @item issuer @tab
117 Holds the issuer's distinguished name.
119 @item validity @tab
120 The activation and expiration dates.
122 @item subject @tab
123 The subject's distinguished name of the certificate.
125 @item extensions @tab
126 The extensions are fields only present in version 3 certificates.
128 @end multitable
129 @caption{X.509 certificate fields.}
130 @end float
132 The certificate's @emph{subject or issuer name} is not just a single
133 string.  It is a Distinguished name and in the @acronym{ASN.1}
134 notation is a sequence of several object identifiers with their corresponding
135 values. Some of available OIDs to be used in an @acronym{X.509}
136 distinguished name are defined in @file{gnutls/x509.h}.
138 The @emph{Version} field in a certificate has values either 1 or 3 for
139 version 3 certificates.  Version 1 certificates do not support the
140 extensions field so it is not possible to distinguish a CA from a
141 person, thus their usage should be avoided.
143 The @emph{validity} dates are there to indicate the date that the
144 specific certificate was activated and the date the certificate's key
145 would be considered invalid.
147 Certificate @emph{extensions} are there to include information about
148 the certificate's subject that did not fit in the typical certificate
149 fields. Those may be e-mail addresses, flags that indicate whether the
150 belongs to a CA etc.  All the supported @acronym{X.509} version 3
151 extensions are shown in @ref{tab:x509-ext}.
153 @float Table,tab:x509-ext
154 @multitable @columnfractions .3 .2 .4
156 @headitem Extension @tab OID @tab Description
158 @item Subject key id @tab 2.5.29.14 @tab
159 An identifier of the key of the subject.
161 @item Authority key id @tab 2.5.29.35 @tab
162 An identifier of the authority's key used to sign the certificate.
164 @item Subject alternative name @tab 2.5.29.17 @tab
165 Alternative names to subject's distinguished name.
167 @item Key usage @tab 2.5.29.15 @tab
168 Constraints the key's usage of the certificate.
170 @item Extended key usage @tab 2.5.29.37 @tab
171 Constraints the purpose of the certificate.
173 @item Basic constraints @tab 2.5.29.19 @tab
174 Indicates whether this is a CA certificate or not, and specify the
175 maximum path lengths of certificate chains.
177 @item CRL distribution points @tab 2.5.29.31 @tab
178 This extension is set by the CA, in order to inform about the issued
179 CRLs.
181 @item Certificate policy @tab 2.5.29.32 @tab
182 This extension is set to indicate the certificate policy as object
183 identifier and may contain a descriptive string or URL.
185 @item Proxy Certification Information @tab 1.3.6.1.5.5.7.1.14 @tab
186 Proxy Certificates includes this extension that contains the OID of
187 the proxy policy language used, and can specify limits on the maximum
188 lengths of proxy chains.  Proxy Certificates are specified in
189 @xcite{RFC3820}.
191 @end multitable
192 @caption{X.509 certificate extensions.}
193 @end float
195 In @acronym{GnuTLS} the @acronym{X.509} certificate structures are
196 handled using the @code{gnutls_x509_crt_t} type and the corresponding
197 private keys with the @code{gnutls_x509_privkey_t} type.  All the
198 available functions for @acronym{X.509} certificate handling have
199 their prototypes in @file{gnutls/x509.h}. An example program to
200 demonstrate the @acronym{X.509} parsing capabilities can be found in
201 @ref{ex:x509-info}.
203 @node Importing an X.509 certificate
204 @subsection Importing an X.509 certificate
206 The certificate structure should be initialized using @funcref{gnutls_x509_crt_init}, and 
207 a certificate structure can be imported using @funcref{gnutls_x509_crt_import}. 
209 @showfuncC{gnutls_x509_crt_init,gnutls_x509_crt_import,gnutls_x509_crt_deinit}
211 In several functions an array of certificates is required. To assist in initialization
212 and import the following two functions are provided.
214 @showfuncB{gnutls_x509_crt_list_import,gnutls_x509_crt_list_import2}
216 In all cases after use a certificate must be deinitialized using @funcref{gnutls_x509_crt_deinit}.
217 Note that although the functions above apply to @code{gnutls_x509_crt_t} structure, similar functions
218 exist for the CRL structure @code{gnutls_x509_crl_t}.
220 @node X.509 distinguished names
221 @subsection X.509 distinguished names
222 @cindex X.509 distinguished name
224 The ``subject'' of an X.509 certificate is not described by
225 a single name, but rather with a distinguished name. This in
226 X.509 terminology is a list of strings each associated an object
227 identifier. To make things simple GnuTLS provides @funcref{gnutls_x509_crt_get_dn}
228 which follows the rules in @xcite{RFC4514} and returns a single
229 string. Access to each string by individual object identifiers
230 can be accessed using @funcref{gnutls_x509_crt_get_dn_by_oid}.
232 @showfuncdesc{gnutls_x509_crt_get_dn}
233 @showfuncdesc{gnutls_x509_crt_get_dn_by_oid}
234 @showfuncdesc{gnutls_x509_crt_get_dn_oid}
236 Similar functions exist to access the distinguished name
237 of the issuer of the certificate.
239 @showfuncD{gnutls_x509_crt_get_issuer_dn,gnutls_x509_crt_get_issuer_dn_by_oid,gnutls_x509_crt_get_issuer_dn_oid,gnutls_x509_crt_get_issuer}
242 @node X.509 public and private keys
243 @subsection Accessing public and private keys
245 Each X.509 certificate contains a public key that corresponds to a private key. To
246 get a unique identifier of the public key the @funcref{gnutls_x509_crt_get_key_id}
247 function is provided. To export the public key or its parameters you may need
248 to convert the X.509 structure to a @code{gnutls_pubkey_t}. See 
249 @ref{Abstract public keys} for more information.
251 @showfuncdesc{gnutls_x509_crt_get_key_id}
253 The private key parameters may be directly accessed by using one of the following functions.
255 @showfuncE{gnutls_x509_privkey_get_pk_algorithm2,gnutls_x509_privkey_export_rsa_raw2,gnutls_x509_privkey_export_ecc_raw,gnutls_x509_privkey_export_dsa_raw,gnutls_x509_privkey_get_key_id}
257 @node Verifying X.509 certificate paths
258 @subsection Verifying @acronym{X.509} certificate paths
259 @cindex verifying certificate paths
261 Verifying certificate paths is important in @acronym{X.509}
262 authentication. For this purpose the following functions are
263 provided.
265 @showfuncdesc{gnutls_x509_trust_list_add_cas}
266 @showfuncdesc{gnutls_x509_trust_list_add_named_crt}
267 @showfuncdesc{gnutls_x509_trust_list_add_crls}
268 @showfuncdesc{gnutls_x509_trust_list_verify_crt}
269 @showfuncdesc{gnutls_x509_trust_list_verify_named_crt}
271 @showfuncdesc{gnutls_x509_trust_list_add_trust_file}
272 @showfuncdesc{gnutls_x509_trust_list_add_trust_mem}
273 @showfuncdesc{gnutls_x509_trust_list_add_system_trust}
275 The verification function will verify a given certificate chain against a list of certificate
276 authorities and certificate revocation lists, and output
277 a bit-wise OR of elements of the @code{gnutls_@-certificate_@-status_t} 
278 enumeration shown in @ref{gnutls_certificate_status_t}. The @code{GNUTLS_@-CERT_@-INVALID} flag
279 is always set on a verification error and more detailed flags will also be set when appropriate.
281 @showenumdesc{gnutls_certificate_status_t,The @code{gnutls_@-certificate_@-status_t} enumeration.}
283 An example of certificate verification is shown in @ref{ex:verify2}.
284 It is also possible to have a set of certificates that
285 are trusted for a particular server but not to authorize other certificates.
286 This purpose is served by the functions @funcref{gnutls_x509_trust_list_add_named_crt} and @funcref{gnutls_x509_trust_list_verify_named_crt}.
288 @node Verifying a certificate in the context of TLS session
289 @subsection Verifying a certificate in the context of TLS session
290 @cindex verifying certificate paths
291 @tindex gnutls_certificate_verify_flags
293 When operating in the context of a TLS session, the trusted certificate
294 authority list may also be set using:
295 @showfuncC{gnutls_certificate_set_x509_trust_file,gnutls_certificate_set_x509_crl_file,gnutls_certificate_set_x509_system_trust}
297 Then it is not required to setup a trusted list as above.
298 The function @funcref{gnutls_certificate_verify_peers3} 
299 may then be used to verify the peer's certificate chain and identity. The flags
300 are set similarly to the verification functions in the previous section.
302 There is also the possibility to pass some input to the verification
303 functions in the form of flags. For @funcref{gnutls_x509_trust_list_verify_crt} the
304 flags are passed straightforward, but
305 @funcref{gnutls_certificate_verify_peers3} depends on the flags set by
306 calling @funcref{gnutls_certificate_set_verify_flags}.  All the available
307 flags are part of the enumeration
308 @code{gnutls_@-certificate_@-verify_@-flags} shown in @ref{gnutls_certificate_verify_flags}.
310 @showenumdesc{gnutls_certificate_verify_flags,The @code{gnutls_@-certificate_@-verify_@-flags} enumeration.}
313 @node OpenPGP certificates
314 @section @acronym{OpenPGP} certificates
315 @cindex OpenPGP certificates
317 The @acronym{OpenPGP} key authentication relies on a distributed trust
318 model, called the ``web of trust''. The ``web of trust'' uses a
319 decentralized system of trusted introducers, which are the same as a
320 CA. @acronym{OpenPGP} allows anyone to sign anyone else's public
321 key. When Alice signs Bob's key, she is introducing Bob's key to
322 anyone who trusts Alice. If someone trusts Alice to introduce keys,
323 then Alice is a trusted introducer in the mind of that observer.
324 For example in @ref{fig:openpgp}, David trusts Alice to be an introducer and Alice
325 signed Bob's key thus Dave trusts Bob's key to be the real one.
327 @float Figure,fig:openpgp
328 @image{gnutls-pgp,8cm}
329 @caption{An example of the OpenPGP trust model.}
330 @end float
332 There are some key points that are important in that model. In the
333 example Alice has to sign Bob's key, only if she is sure that the key
334 belongs to Bob. Otherwise she may also make Dave falsely believe that
335 this is Bob's key. Dave has also the responsibility to know who to
336 trust.  This model is similar to real life relations.
338 Just see how Charlie behaves in the previous example. Although he has
339 signed Bob's key - because he knows, somehow, that it belongs to Bob -
340 he does not trust Bob to be an introducer. Charlie decided to trust
341 only Kevin, for some reason. A reason could be that Bob is lazy
342 enough, and signs other people's keys without being sure that they
343 belong to the actual owner.
345 @float Table,tab:openpgp-certificate
346 @multitable @columnfractions .2 .7
348 @headitem Field @tab Description
350 @item version @tab
351 The field that indicates the version of the OpenPGP structure.
353 @item user ID @tab
354 An RFC 2822 string that identifies the owner of the key. There may be
355 multiple user identifiers in a key.
357 @item public key @tab
358 The main public key of the certificate.
360 @item expiration @tab
361 The expiration time of the main public key.
363 @item public subkey @tab
364 An additional public key of the certificate. There may be multiple subkeys
365 in a certificate.
367 @item public subkey expiration @tab
368 The expiration time of the subkey.
370 @end multitable
371 @caption{OpenPGP certificate fields.}
372 @end float
375 @subsection @acronym{OpenPGP} certificate structure
377 In @acronym{GnuTLS} the @acronym{OpenPGP} certificate structures
378 @xcite{RFC2440} are handled using the @code{gnutls_openpgp_crt_t} type.
379 A typical certificate contains the user ID, which is an RFC 2822
380 mail and name address, a public key, possibly a number of additional
381 public keys (called subkeys), and a number of signatures. The various
382 fields are shown in @ref{tab:openpgp-certificate}.
384 The additional subkeys may provide key for various different purposes,
385 e.g. one key to encrypt mail, and another to sign a TLS key exchange.
386 Each subkey is identified by a unique key ID.
387 The keys that are to be used in a TLS key exchange that requires
388 signatures are called authentication keys in the OpenPGP jargon.
389 The mapping of TLS key exchange methods to public keys is shown in
390 @ref{tab:openpgp-key-exchange}.
392 @float Table,tab:openpgp-key-exchange
393 @multitable @columnfractions .2 .7
395 @headitem Key exchange @tab Public key requirements
397 @item RSA @tab
398 An RSA public key that allows encryption.
400 @item DHE_@-RSA @tab
401 An RSA public key that is marked for authentication.
403 @item ECDHE_@-RSA @tab
404 An RSA public key that is marked for authentication.
406 @item DHE_@-DSS @tab
407 A DSA public key that is marked for authentication.
409 @end multitable
410 @caption{The types of (sub)keys required for the various TLS key exchange methods.}
411 @end float
413 The corresponding private keys are stored in the
414 @code{gnutls_openpgp_privkey_t} type. All the prototypes for the key
415 handling functions can be found in @file{gnutls/openpgp.h}.
417 @subsection Verifying an @acronym{OpenPGP} certificate
419 The verification functions of @acronym{OpenPGP} keys, included in
420 @acronym{GnuTLS}, are simple ones, and do not use the features of the
421 ``web of trust''.  For that reason, if the verification needs are
422 complex, the assistance of external tools like @acronym{GnuPG} and
423 GPGME@footnote{@url{http://www.gnupg.org/related_software/gpgme/}} is
424 recommended.
426 In GnuTLS there is a verification function for OpenPGP certificates,
427 the @funcref{gnutls_openpgp_crt_verify_ring}.  This checks an
428 @acronym{OpenPGP} key against a given set of public keys (keyring) and
429 returns the key status. The key verification status is the same as in
430 @acronym{X.509} certificates, although the meaning and interpretation
431 are different. For example an @acronym{OpenPGP} key may be valid, if
432 the self signature is ok, even if no signers were found.  The meaning
433 of verification status flags is the same as in the @acronym{X.509} certificates
434 (see @ref{gnutls_certificate_verify_flags}).
436 @showfuncdesc{gnutls_openpgp_crt_verify_ring}
438 @showfuncdesc{gnutls_openpgp_crt_verify_self}
440 @subsection Verifying a certificate in the context of a TLS session
442 Similarly with X.509 certificates, one needs to specify
443 the OpenPGP keyring file in the credentials structure. The certificates
444 in this file will be  used by @funcref{gnutls_certificate_verify_peers3}
445 to verify the signatures in the certificate sent by the peer.
447 @showfuncdesc{gnutls_certificate_set_openpgp_keyring_file}
449 @node Advanced certificate verification
450 @section Advanced certificate verification
451 @cindex Certificate verification
453 The verification of X.509 certificates in the HTTPS and other Internet protocols is typically 
454 done by loading a trusted list of commercial Certificate Authorities
455 (see @funcref{gnutls_certificate_set_x509_system_trust}), and using them as trusted anchors.
456 However, there are several examples (eg. the Diginotar incident) where one of these
457 authorities was compromised. This risk can be mitigated by using in addition to CA certificate verification,
458 other verification methods. In this section we list the available in GnuTLS methods.
460 @menu
461 * Verifying a certificate using trust on first use authentication::
462 * Verifying a certificate using DANE (DNSSEC)::
463 @end menu
465 @node Verifying a certificate using trust on first use authentication
466 @subsection Verifying a certificate using trust on first use authentication
467 @cindex verifying certificate paths
468 @cindex SSH-style authentication
469 @cindex Trust on first use
470 @cindex Key pinning
472 It is possible to use a trust on first use (TOFU) authentication 
473 method in GnuTLS. That is the concept used by the SSH programs, where the 
474 public key of the peer is not verified, or verified in an out-of-bound way,
475 but subsequent connections to the same peer require the public key to 
476 remain the same.  Such a system in combination with the typical CA 
477 verification of a certificate, and OCSP revocation checks,
478 can help to provide multiple factor verification, where a single point of
479 failure is not enough to compromise the system. For example a server compromise
480 may be detected using OCSP, and a CA compromise can be detected using
481 the trust on first use method.
482 Such a hybrid system with X.509 and trust on first use authentication is 
483 shown in @ref{Simple client example with SSH-style certificate verification}.
485 See @ref{Certificate verification} on how to use the available functionality.
487 @node Verifying a certificate using DANE (DNSSEC)
488 @subsection Verifying a certificate using DANE (DNSSEC)
489 @cindex verifying certificate paths
490 @cindex DANE
491 @cindex DNSSEC
493 The DANE protocol is a protocol that can be used to verify TLS certificates
494 using the DNS (or better DNSSEC) protocols. The DNS security extensions (DNSSEC)
495 provide an alternative public key infrastructure to the commercial CAs that
496 are typically used to sign TLS certificates. The DANE protocol takes advantage
497 of the DNSSEC infrastructure to verify TLS certificates. This can be 
498 in addition to the verification by CA infrastructure or 
499 may even replace it where DNSSEC is fully deployed. Note however, that DNSSEC deployment is
500 fairly new and it would be better to use it as an additional verification
501 method rather than the only one.
503 The DANE functionality is provided by the @code{libgnutls-dane} library that is shipped
504 with GnuTLS and the function prototypes are in @code{gnutls/dane.h}. 
505 See @ref{Certificate verification} for information on how to use the library.
507 @node Digital signatures
508 @section Digital signatures
509 @cindex digital signatures
511 In this section we will provide some information about digital
512 signatures, how they work, and give the rationale for disabling some
513 of the algorithms used.
515 Digital signatures work by using somebody's secret key to sign some
516 arbitrary data.  Then anybody else could use the public key of that
517 person to verify the signature.  Since the data may be arbitrary it is
518 not suitable input to a cryptographic digital signature algorithm. For
519 this reason and also for performance cryptographic hash algorithms are
520 used to preprocess the input to the signature algorithm. This works as
521 long as it is difficult enough to generate two different messages with
522 the same hash algorithm output. In that case the same signature could
523 be used as a proof for both messages. Nobody wants to sign an innocent
524 message of donating 1 euro to Greenpeace and find out that he
525 donated 1.000.000 euros to Bad Inc.
527 For a hash algorithm to be called cryptographic the following three
528 requirements must hold:
530 @enumerate
531 @item Preimage resistance.
532 That means the algorithm must be one way and given the output of the
533 hash function @math{H(x)}, it is impossible to calculate @math{x}.
535 @item 2nd preimage resistance.
536 That means that given a pair @math{x,y} with @math{y=H(x)} it is
537 impossible to calculate an @math{x'} such that @math{y=H(x')}.
539 @item Collision resistance.
540 That means that it is impossible to calculate random @math{x} and
541 @math{x'} such @math{H(x')=H(x)}.
542 @end enumerate
544 The last two requirements in the list are the most important in
545 digital signatures. These protect against somebody who would like to
546 generate two messages with the same hash output. When an algorithm is
547 considered broken usually it means that the Collision resistance of
548 the algorithm is less than brute force. Using the birthday paradox the
549 brute force attack takes
550 @iftex
551 @math{2^{(\rm{hash\ size}) / 2}}
552 @end iftex
553 @ifnottex
554 @math{2^{((hash size) / 2)}}
555 @end ifnottex
556 operations. Today colliding certificates using the MD5 hash algorithm
557 have been generated as shown in @xcite{WEGER}.
559 There has been cryptographic results for the SHA-1 hash algorithms as
560 well, although they are not yet critical.  Before 2004, MD5 had a
561 presumed collision strength of @math{2^{64}}, but it has been showed
562 to have a collision strength well under @math{2^{50}}.  As of November
563 2005, it is believed that SHA-1's collision strength is around
564 @math{2^{63}}.  We consider this sufficiently hard so that we still
565 support SHA-1.  We anticipate that SHA-256/386/512 will be used in
566 publicly-distributed certificates in the future.  When @math{2^{63}}
567 can be considered too weak compared to the computer power available
568 sometime in the future, SHA-1 will be disabled as well.  The collision
569 attacks on SHA-1 may also get better, given the new interest in tools
570 for creating them.
572 @subsection Trading security for interoperability
574 If you connect to a server and use GnuTLS' functions to verify the
575 certificate chain, and get a @code{GNUTLS_CERT_INSECURE_ALGORITHM}
576 validation error (see @ref{Verifying X.509 certificate paths}), it means
577 that somewhere in the certificate chain there is a certificate signed
578 using @code{RSA-MD2} or @code{RSA-MD5}.  These two digital signature
579 algorithms are considered broken, so GnuTLS fails verifying
580 the certificate.  In some situations, it may be useful to be
581 able to verify the certificate chain anyway, assuming an attacker did
582 not utilize the fact that these signatures algorithms are broken.
583 This section will give help on how to achieve that.
585 It is important to know that you do not have to enable any of
586 the flags discussed here to be able to use trusted root CA
587 certificates self-signed using @code{RSA-MD2} or @code{RSA-MD5}. The
588 certificates in the trusted list are considered trusted irrespective
589 of the signature.
591 If you are using @funcref{gnutls_certificate_verify_peers3} to verify the
592 certificate chain, you can call
593 @funcref{gnutls_certificate_set_verify_flags} with the flags:
594 @itemize
595 @item @code{GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2}
596 @item @code{GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5}
597 @end itemize
598 as in the following example:
600 @example
601   gnutls_certificate_set_verify_flags (x509cred,
602                                        GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5);
603 @end example
605 This will signal the verifier algorithm to enable @code{RSA-MD5} when
606 verifying the certificates.
608 If you are using @funcref{gnutls_x509_crt_verify} or
609 @funcref{gnutls_x509_crt_list_verify}, you can pass the
610 @code{GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5} parameter directly in the
611 @code{flags} parameter.
613 If you are using these flags, it may also be a good idea to warn the
614 user when verification failure occur for this reason.  The simplest is
615 to not use the flags by default, and only fall back to using them
616 after warning the user.  If you wish to inspect the certificate chain
617 yourself, you can use @funcref{gnutls_certificate_get_peers} to extract
618 the raw server's certificate chain, @funcref{gnutls_x509_crt_list_import} to parse each of the certificates, and
619 then @funcref{gnutls_x509_crt_get_signature_algorithm} to find out the
620 signing algorithm used for each certificate.  If any of the
621 intermediary certificates are using @code{GNUTLS_SIGN_RSA_MD2} or
622 @code{GNUTLS_SIGN_RSA_MD5}, you could present a warning.