diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,9 @@
-2021-04-19  Vladimir Shabanov  <dev@vshabanov.com>
-
-	* HsOpenSSL.cabal (Version): Bump version to 0.11.7
+2021-07-28  Vladimir Shabanov  <dev@vshabanov.com>
 
-	* Added Session.contextSetDefaultVerifyPaths
-	by Alexander Biehl @alexbiehl (#59)
+	* HsOpenSSL.cabal (Version): Bump version to 0.11.7.1
 
-	* Fix for LibreSSL (#58)
+	* Fix SSL_CTX_set_session_id_context #61
+	by @flobrosch (#61)
 
 2021-04-05  Vladimir Shabanov  <dev@vshabanov.com>
 
diff --git a/HsOpenSSL.cabal b/HsOpenSSL.cabal
--- a/HsOpenSSL.cabal
+++ b/HsOpenSSL.cabal
@@ -10,7 +10,7 @@
     systems and stable. You may also be interested in the @tls@ package,
     <http://hackage.haskell.org/package/tls>, which is a pure Haskell
     implementation of SSL.
-Version:       0.11.7
+Version:       0.11.7.1
 License:       PublicDomain
 License-File:  COPYING
 Author:        Adam Langley, Mikhail Vorozhtsov, PHO, Taru Karttunen
diff --git a/OpenSSL/Cipher.hsc b/OpenSSL/Cipher.hsc
--- a/OpenSSL/Cipher.hsc
+++ b/OpenSSL/Cipher.hsc
@@ -1,6 +1,3 @@
-#include "HsOpenSSL.h"
-#include "openssl/aes.h"
-
 {-# LANGUAGE EmptyDataDecls           #-}
 {-# LANGUAGE ForeignFunctionInterface #-}
 -- | This module interfaces to some of the OpenSSL ciphers without using
@@ -24,7 +21,8 @@
 #endif
     )
     where
-
+#include "HsOpenSSL.h"
+#include "openssl/aes.h"
 import           Control.Monad (when, unless)
 import           Data.IORef
 import           Foreign
diff --git a/OpenSSL/Session.hsc b/OpenSSL/Session.hsc
--- a/OpenSSL/Session.hsc
+++ b/OpenSSL/Session.hsc
@@ -79,7 +79,7 @@
 
   ) where
 
-#include "HsOpenSSL.h"
+#include "openssl/ssl.h"
 
 import Prelude hiding (
 #if !MIN_VERSION_base(4,6,0)
@@ -363,7 +363,7 @@
            >>= wrapX509Store (touchContext context)
 
 foreign import ccall unsafe "SSL_CTX_set_session_id_context"
-  _ssl_set_session_id_context :: Ptr SSLContext_ -> Ptr CChar -> CSize -> IO CInt
+  _ssl_set_session_id_context :: Ptr SSLContext_ -> Ptr CChar -> CUInt -> IO CInt
 
 -- | Set context within which session can be reused (server side only).
 --
@@ -523,13 +523,11 @@
   (#const SSL_ERROR_WANT_CONNECT) -> "SSL_ERROR_WANT_CONNECT"
   (#const SSL_ERROR_WANT_ACCEPT) -> "SSL_ERROR_WANT_ACCEPT"
   (#const SSL_ERROR_WANT_X509_LOOKUP) -> "SSL_ERROR_WANT_X509_LOOKUP"
-#if defined(SSL_ERROR_WANT_ASYNC)
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
   (#const SSL_ERROR_WANT_ASYNC) -> "SSL_ERROR_WANT_ASYNC"
-#endif
-#if defined(SSL_ERROR_WANT_ASYNC_JOB)
   (#const SSL_ERROR_WANT_ASYNC_JOB) -> "SSL_ERROR_WANT_ASYNC_JOB"
 #endif
-#if defined(SSL_ERROR_WANT_CLIENT_HELLO_CB)
+#if OPENSSL_VERSION_NUMBER >= 0x10101000L
   (#const SSL_ERROR_WANT_CLIENT_HELLO_CB) -> "SSL_ERROR_WANT_CLIENT_HELLO_CB"
 #endif
   (#const SSL_ERROR_SYSCALL) -> "SSL_ERROR_SYSCALL"
