OpenSSL 1.1.0 Changes

From OpenSSLWiki
Revision as of 20:24, 27 June 2016 by Rsalz (talk | contribs)

Jump to: navigation, search

This is a parent page for discussion about API changes being done for OpenSSL version 1.1

The overall goal of this project is to make most data structures opaque to applications. This provides us with a number of benefits:

  • We can add fields without breaking binary compatibility
  • Applications are more robust and can be more assured about correctness
  • It helps us determine which (new) accessors and settors, for example, are needed

Please add sub-pages to discuss particular parts of the library as work progresses.

Major Changes so far

  • All structures in libssl public header files have been removed so that they are "opaque" to library users. You should use the provided accessor functions instead
  • The old DES API has been removed
  • bn, a sub library in libcrypto, has been made opaque
  • Access to deprecated functions/macros has been removed by default. To enable access you must do two things. 1) Build OpenSSL with deprecation support (pass "enable-deprecated" as an argument to config) 2) Applications must define "OPENSSL_USE_DEPRECATED" before including OpenSSL header files
  • HMAC_Init and HMAC_cleanup were previously stated in the docs and header files as being deprecated - but were not flagged in previous versions with OPENSSL_NO_DEPRECATED. This has been corrected in 1.1.0. Access to these functions/macros will be off by default in 1.1.0 as per the note above about deprecation.


Various functions get deprecated as other interfaces get added, but are still available in a default build. The include files support setting the OPENSSL_API_COMPAT define that will hide functions that are deprecated in the selected version. To select the 1.1.0 version use -DOPENSSL_API_COMPAT=0x10100000L.

Backward compatibility

Since some structures have become opaque you can't directly access the member any more. You might need to create backward compatible macros or functions if you still want to support older versions of OpenSSL. A suggested way of doing that is:

#define OBJ_get0_data(o) ((o)->data)
#define OBJ_length(o) ((o)->length)

Adding forward-compatible code to older versions

Application code now has to use pointers, and cannot allocate objects directly on the stack. One way to do this is to add in missing constructors like this:

HMAC_CTX *HMAC_CTX_new(void)
   HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
   if (ctx != NULL) {
       if (!HMAC_CTX_reset(ctx)) {
           return NULL;
   return ctx;
void HMAC_CTX_free(HMAC_CTX *ctx)
   if (ctx != NULL) {

In other words, look at the 1.1 code and add the missing functions into your source.

Things that Broke in Qt

Here's what's broken in the dev branch of Qt when building openssl master as of 6 Feb 2015.

  • DH - we were directly accessing p and q to set the DH params to primes embedded in Qt. We can probably replace this with SSL_CTX_set_dh_auto(ctx, 1). Another option suggested by Steve Henson is to save the DHparams we're using at the moment then use d2i_DHparams to load them in. This is compatible with openssl versions that don't have the dh_auto option.
  • ctx->cert_store - we were directly accessing the cert_store field of SSL_CTX. We can probably replace this with X509_STORE *SSL_CTX_get_cert_store(SSL_CTX *ctx) [Fixed in dev]
  • session->tlsext_tick_lifetime_hint - we were directly accessing the lifetime hint of the session. [A new API to access this field has been added]
  • cipher->valid - we were directly accessing the valid field of SSL_CIPHER. No replacement found. [This turned out not to be needed and so will be removed].

Things that Broke in Curl

  • SSL_SESSION->ssl_version. Replaced with SSL_version(SSL *)

Things that Broke in wget

  • SSL->state. Replaced with SSL_state(SSL *)

Things that Broke in Apache Traffic Manager

  • Setting SSL->rbio without setting SSL->wbio. New function introduction in 1.1.0 to handle this: SSL_set_rbio()

Things that Broke in OpenConnect

In order to simulate "resume" of a DTLS session which never really existed but which was actually negotiated over the VPN control connection, this code in the OpenConnect VPN client needs to set the following fields in a new SSL_SESSION:

  • ->ssl_version
  • ->cipher{,_id}
  • ->master_key{,_length}
  • ->session_id{,_length}

This was fixed with this OpenConnect commit which makes it create the ASN.1 representation of the session and import it with d2i_SSL_SESSION(). This is done conditionally in the above patch because it depends on the fix in openssl HEAD for d2i_SSL_SESSION() to make it cope with DTLS1_BAD_VER (RT#3704).

Other simpler things which broke:

  • SSL_CIPHER->id. Replaced with SSL_CIPHER_get_id()
  • SSL_CTX->extra_certs. Replaced with SSL_CTX_get_extra_chain_certs_only()

Things that Broke in TianoCore/EDKII

EDKII is the reference implementation of UEFI firmware.

  • Various implicit inclusions of <openssl/bn.h> and <openssl/rsa.h> needed to be made explicit. (commit)
  • X509_NAME->bytes->{data,length}. Replaced with i2d_X509_NAME() (commit)
  • X509_ATTRIBUTE->{object,value}. Replaced with X509_ATTRIBUTE_get0_object() and X509_ATTRIBUTE_get0_type() (commit)
  • ASN1_OBJECT->{length,data}. Replaced with OBJ_get0_data() and OBJ_length(). With backward-compatibility #define of same. (commit)