Implement legacy OCSP APIs for libssl. Previously, we'd omitted OpenSSL's OCSP APIs because they depend on a complex OCSP mechanism and encourage the the unreliable server behavior that hampers using OCSP stapling to fix revocation today. (OCSP responses should not be fetched on-demand on a callback. They should be managed like other server credentials and refreshed eagerly, so temporary CA outage does not translate to loss of OCSP.) But most of the APIs are byte-oriented anyway, so they're easy to support. Intentionally omit the one that takes a bunch of OCSP_RESPIDs. The callback is benign on the client (an artifact of OpenSSL reading OCSP and verifying certificates in the wrong order). On the server, it encourages unreliability, but pyOpenSSL/cryptography.io depends on this. Dcument that this is only for compatibility with legacy software. Also tweak a few things for compatilibility. cryptography.io expects SSL_CTX_set_read_ahead to return something, SSL_get_server_tmp_key's signature was wrong, and cryptography.io tries to redefine SSL_get_server_tmp_key if SSL_CTRL_GET_SERVER_TMP_KEY is missing. Change-Id: I2f99711783456bfb7324e9ad972510be8a95e845 Reviewed-on: https://boringssl-review.googlesource.com/28404 Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org> Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/ssl_lib.cc b/ssl/ssl_lib.cc index 8fb9ada..606d1fc 100644 --- a/ssl/ssl_lib.cc +++ b/ssl/ssl_lib.cc
@@ -1664,9 +1664,9 @@ int SSL_get_read_ahead(const SSL *ssl) { return 0; } -void SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes) { } +int SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes) { return 1; } -void SSL_set_read_ahead(SSL *ssl, int yes) { } +int SSL_set_read_ahead(SSL *ssl, int yes) { return 1; } int SSL_pending(const SSL *ssl) { return static_cast<int>(ssl->s3->pending_app_data.size()); @@ -2321,7 +2321,7 @@ const COMP_METHOD *SSL_get_current_expansion(SSL *ssl) { return NULL; } -int *SSL_get_server_tmp_key(SSL *ssl, EVP_PKEY **out_key) { return 0; } +int SSL_get_server_tmp_key(SSL *ssl, EVP_PKEY **out_key) { return 0; } void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode) { ctx->quiet_shutdown = (mode != 0); @@ -2872,3 +2872,36 @@ const SSL_TICKET_AEAD_METHOD *aead_method) { ctx->ticket_aead_method = aead_method; } + +int SSL_set_tlsext_status_type(SSL *ssl, int type) { + if (!ssl->config) { + return 0; + } + ssl->config->ocsp_stapling_enabled = type == TLSEXT_STATUSTYPE_ocsp; + return 1; +} + +int SSL_set_tlsext_status_ocsp_resp(SSL *ssl, uint8_t *resp, size_t resp_len) { + if (SSL_set_ocsp_response(ssl, resp, resp_len)) { + OPENSSL_free(resp); + return 1; + } + return 0; +} + +size_t SSL_get_tlsext_status_ocsp_resp(const SSL *ssl, const uint8_t **out) { + size_t ret; + SSL_get0_ocsp_response(ssl, out, &ret); + return ret; +} + +int SSL_CTX_set_tlsext_status_cb(SSL_CTX *ctx, + int (*callback)(SSL *ssl, void *arg)) { + ctx->legacy_ocsp_callback = callback; + return 1; +} + +int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg) { + ctx->legacy_ocsp_callback_arg = arg; + return 1; +}