OLD | NEW |
1 /* | 1 /* |
2 * This file contains prototypes for the public SSL functions. | 2 * This file contains prototypes for the public SSL functions. |
3 * | 3 * |
4 * This Source Code Form is subject to the terms of the Mozilla Public | 4 * This Source Code Form is subject to the terms of the Mozilla Public |
5 * License, v. 2.0. If a copy of the MPL was not distributed with this | 5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 /* $Id: ssl.h,v 1.59 2012/09/21 21:58:43 wtc%google.com Exp $ */ | 7 /* $Id$ */ |
8 | 8 |
9 #ifndef __ssl_h_ | 9 #ifndef __ssl_h_ |
10 #define __ssl_h_ | 10 #define __ssl_h_ |
11 | 11 |
12 #include "prtypes.h" | 12 #include "prtypes.h" |
13 #include "prerror.h" | 13 #include "prerror.h" |
14 #include "prio.h" | 14 #include "prio.h" |
15 #include "seccomon.h" | 15 #include "seccomon.h" |
16 #include "cert.h" | 16 #include "cert.h" |
17 #include "keyt.h" | 17 #include "keyt.h" |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 417 |
418 /* | 418 /* |
419 ** Return the certificate for our SSL peer. If the client calls this | 419 ** Return the certificate for our SSL peer. If the client calls this |
420 ** it will always return the server's certificate. If the server calls | 420 ** it will always return the server's certificate. If the server calls |
421 ** this, it may return NULL if client authentication is not enabled or | 421 ** this, it may return NULL if client authentication is not enabled or |
422 ** if the client had no certificate when asked. | 422 ** if the client had no certificate when asked. |
423 ** "fd" the socket "file" descriptor | 423 ** "fd" the socket "file" descriptor |
424 */ | 424 */ |
425 SSL_IMPORT CERTCertificate *SSL_PeerCertificate(PRFileDesc *fd); | 425 SSL_IMPORT CERTCertificate *SSL_PeerCertificate(PRFileDesc *fd); |
426 | 426 |
| 427 /* SSL_PeerStapledOCSPResponses returns the OCSP responses that were provided |
| 428 * by the TLS server. The return value is a pointer to an internal SECItemArray |
| 429 * that contains the returned OCSP responses; it is only valid until the |
| 430 * callback function that calls SSL_PeerStapledOCSPResponses returns. |
| 431 * |
| 432 * If no OCSP responses were given by the server then the result will be empty. |
| 433 * If there was an error, then the result will be NULL. |
| 434 * |
| 435 * You must set the SSL_ENABLE_OCSP_STAPLING option to enable OCSP stapling. |
| 436 * to be provided by a server. |
| 437 * |
| 438 * libssl does not do any validation of the OCSP response itself; the |
| 439 * authenticate certificate hook is responsible for doing so. The default |
| 440 * authenticate certificate hook, SSL_AuthCertificate, does not implement |
| 441 * any OCSP stapling funtionality, but this may change in future versions. |
| 442 */ |
| 443 SSL_IMPORT const SECItemArray * SSL_PeerStapledOCSPResponses(PRFileDesc *fd); |
| 444 |
| 445 /* SSL_SetStapledOCSPResponses stores an array of one or multiple OCSP responses |
| 446 * in the fd's data, which may be sent as part of a server side cert_status |
| 447 * handshake message. |
| 448 * If takeOwnership is false, the function will duplicate the responses. |
| 449 * If takeOwnership is true, the ownership of responses is transfered into the |
| 450 * SSL library, and the caller must stop using it. |
| 451 */ |
| 452 SSL_IMPORT SECStatus |
| 453 SSL_SetStapledOCSPResponses(PRFileDesc *fd, SECItemArray *responses, |
| 454 PRBool takeOwnership); |
| 455 |
427 /* | 456 /* |
428 ** Return references to the certificates presented by the SSL peer. | 457 ** Return references to the certificates presented by the SSL peer. |
429 ** |maxNumCerts| must contain the size of the |certs| array. On successful | 458 ** |maxNumCerts| must contain the size of the |certs| array. On successful |
430 ** return, |*numCerts| contains the number of certificates available and | 459 ** return, |*numCerts| contains the number of certificates available and |
431 ** |certs| will contain references to as many certificates as would fit. | 460 ** |certs| will contain references to as many certificates as would fit. |
432 ** Therefore if |*numCerts| contains a value less than or equal to | 461 ** Therefore if |*numCerts| contains a value less than or equal to |
433 ** |maxNumCerts|, then all certificates were returned. | 462 ** |maxNumCerts|, then all certificates were returned. |
434 */ | 463 */ |
435 SSL_IMPORT SECStatus SSL_PeerCertificateChain( | 464 SSL_IMPORT SECStatus SSL_PeerCertificateChain( |
436 PRFileDesc *fd, CERTCertificate **certs, | 465 PRFileDesc *fd, CERTCertificate **certs, |
437 unsigned int *numCerts, unsigned int maxNumCerts); | 466 unsigned int *numCerts, unsigned int maxNumCerts); |
438 | 467 |
439 /* SSL_GetStapledOCSPResponse returns the OCSP response that was provided by | |
440 * the TLS server. The resulting data is copied to |out_data|. On entry, |*len| | |
441 * must contain the size of |out_data|. On exit, |*len| will contain the size | |
442 * of the OCSP stapled response. If the stapled response is too large to fit in | |
443 * |out_data| then it will be truncated. If no OCSP response was given by the | |
444 * server then it has zero length. | |
445 * | |
446 * You must set the SSL_ENABLE_OCSP_STAPLING option in order for OCSP responses | |
447 * to be provided by a server. | |
448 * | |
449 * You can call this function during the certificate verification callback or | |
450 * any time afterwards. | |
451 */ | |
452 SSL_IMPORT SECStatus SSL_GetStapledOCSPResponse(PRFileDesc *fd, | |
453 unsigned char *out_data, | |
454 unsigned int *len); | |
455 | |
456 /* | 468 /* |
457 ** Authenticate certificate hook. Called when a certificate comes in | 469 ** Authenticate certificate hook. Called when a certificate comes in |
458 ** (because of SSL_REQUIRE_CERTIFICATE in SSL_Enable) to authenticate the | 470 ** (because of SSL_REQUIRE_CERTIFICATE in SSL_Enable) to authenticate the |
459 ** certificate. | 471 ** certificate. |
460 ** | 472 ** |
461 ** The authenticate certificate hook must return SECSuccess to indicate the | 473 ** The authenticate certificate hook must return SECSuccess to indicate the |
462 ** certificate is valid, SECFailure to indicate the certificate is invalid, | 474 ** certificate is valid, SECFailure to indicate the certificate is invalid, |
463 ** or SECWouldBlock if the application will authenticate the certificate | 475 ** or SECWouldBlock if the application will authenticate the certificate |
464 ** asynchronously. SECWouldBlock is only supported for non-blocking sockets. | 476 ** asynchronously. SECWouldBlock is only supported for non-blocking sockets. |
465 ** | 477 ** |
466 ** If the authenticate certificate hook returns SECFailure, then the bad cert | 478 ** If the authenticate certificate hook returns SECFailure, then the bad cert |
467 ** hook will be called. The bad cert handler is NEVER called if the | 479 ** hook will be called. The bad cert handler is NEVER called if the |
468 ** authenticate certificate hook returns SECWouldBlock. If the application | 480 ** authenticate certificate hook returns SECWouldBlock. If the application |
469 ** needs to handle and/or override a bad cert, it should do so before it | 481 ** needs to handle and/or override a bad cert, it should do so before it |
470 ** calls SSL_AuthCertificateComplete (modifying the error it passes to | 482 ** calls SSL_AuthCertificateComplete (modifying the error it passes to |
471 ** SSL_AuthCertificateComplete as needed). | 483 ** SSL_AuthCertificateComplete as needed). |
472 ** | 484 ** |
473 ** See the documentation for SSL_AuthCertificateComplete for more information | 485 ** See the documentation for SSL_AuthCertificateComplete for more information |
474 ** about the asynchronous behavior that occurs when the authenticate | 486 ** about the asynchronous behavior that occurs when the authenticate |
475 ** certificate hook returns SECWouldBlock. | 487 ** certificate hook returns SECWouldBlock. |
| 488 ** |
| 489 ** RFC 6066 says that clients should send the bad_certificate_status_response |
| 490 ** alert when they encounter an error processing the stapled OCSP response. |
| 491 ** libssl does not provide a way for the authenticate certificate hook to |
| 492 ** indicate that an OCSP error (SEC_ERROR_OCSP_*) that it returns is an error |
| 493 ** in the stapled OCSP response or an error in some other OCSP response. |
| 494 ** Further, NSS does not provide a convenient way to control or determine |
| 495 ** which OCSP response(s) were used to validate a certificate chain. |
| 496 ** Consequently, the current version of libssl does not ever send the |
| 497 ** bad_certificate_status_response alert. This may change in future releases. |
476 */ | 498 */ |
477 typedef SECStatus (PR_CALLBACK *SSLAuthCertificate)(void *arg, PRFileDesc *fd, | 499 typedef SECStatus (PR_CALLBACK *SSLAuthCertificate)(void *arg, PRFileDesc *fd, |
478 PRBool checkSig, | 500 PRBool checkSig, |
479 PRBool isServer); | 501 PRBool isServer); |
480 | 502 |
481 SSL_IMPORT SECStatus SSL_AuthCertificateHook(PRFileDesc *fd, | 503 SSL_IMPORT SECStatus SSL_AuthCertificateHook(PRFileDesc *fd, |
482 SSLAuthCertificate f, | 504 SSLAuthCertificate f, |
483 void *arg); | 505 void *arg); |
484 | 506 |
485 /* An implementation of the certificate authentication hook */ | 507 /* An implementation of the certificate authentication hook */ |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 * should continue using the connection. If the application passes a non-zero | 1092 * should continue using the connection. If the application passes a non-zero |
1071 * value for second argument (error), or if SSL_AuthCertificateComplete returns | 1093 * value for second argument (error), or if SSL_AuthCertificateComplete returns |
1072 * anything other than SECSuccess, then the application should close the | 1094 * anything other than SECSuccess, then the application should close the |
1073 * connection. | 1095 * connection. |
1074 */ | 1096 */ |
1075 SSL_IMPORT SECStatus SSL_AuthCertificateComplete(PRFileDesc *fd, | 1097 SSL_IMPORT SECStatus SSL_AuthCertificateComplete(PRFileDesc *fd, |
1076 PRErrorCode error); | 1098 PRErrorCode error); |
1077 SEC_END_PROTOS | 1099 SEC_END_PROTOS |
1078 | 1100 |
1079 #endif /* __ssl_h_ */ | 1101 #endif /* __ssl_h_ */ |
OLD | NEW |