Skip to content

Commit 2c86b34

Browse files
committed
Updates for OpenSSL 1.1.0
1 parent 0f62c7e commit 2c86b34

File tree

6 files changed

+17
-23
lines changed

6 files changed

+17
-23
lines changed

HsOpenSSL.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ Library
127127
OpenSSL.BIO
128128
OpenSSL.ERR
129129
OpenSSL.Objects
130-
OpenSSL.SSL
131130
OpenSSL.SSL.Option
132131
OpenSSL.Stack
133132
OpenSSL.Utils

OpenSSL.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ module OpenSSL
4646
where
4747
import Control.Concurrent.MVar
4848
import Control.Monad
49-
import OpenSSL.SSL
5049
import System.IO.Unsafe
5150

5251
#if !MIN_VERSION_base(4,6,0)
5352
import Control.Exception (onException, mask_)
5453
#endif
5554

55+
foreign import ccall "HsOpenSSL_init"
56+
initSSL :: IO ()
57+
5658
foreign import ccall "HsOpenSSL_setupMutex"
5759
setupMutex :: IO ()
5860

@@ -81,9 +83,7 @@ withOpenSSL io
8183
-- We don't want our initialisation sequence to be interrupted
8284
-- halfway.
8385
= do modifyMVarMasked_ isInitialised $ \ done ->
84-
do unless done $ do loadErrorStrings
85-
addAllAlgorithms
86-
libraryInit
86+
do unless done $ do initSSL
8787
setupMutex
8888
return True
8989
io

OpenSSL/SSL.hs

Lines changed: 0 additions & 16 deletions
This file was deleted.

OpenSSL/Session.hsc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ data SSLMethod_
136136

137137
foreign import ccall unsafe "SSL_CTX_new" _ssl_ctx_new :: Ptr SSLMethod_ -> IO (Ptr SSLContext_)
138138
foreign import ccall unsafe "SSL_CTX_free" _ssl_ctx_free :: Ptr SSLContext_ -> IO ()
139+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
140+
foreign import ccall unsafe "TLS_method" _ssl_method :: IO (Ptr SSLMethod_)
141+
#else
139142
foreign import ccall unsafe "SSLv23_method" _ssl_method :: IO (Ptr SSLMethod_)
143+
#endif
140144

141145
-- | Create a new SSL context.
142146
context :: IO SSLContext

cbits/HsOpenSSL.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44
#include "mutex.h"
55

66
/* OpenSSL ********************************************************************/
7-
void HsOpenSSL_OpenSSL_add_all_algorithms() {
7+
void HsOpenSSL_init() {
8+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
9+
// OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
10+
// unnecessary in OpenSSL 1.1.0
11+
#else
12+
SSL_load_error_strings();
813
OpenSSL_add_all_algorithms();
14+
SSL_library_init();
15+
#endif
916
}
1017

1118
void HsOpenSSL_OPENSSL_free(void* ptr) {

cbits/HsOpenSSL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#endif
3434

3535
/* OpenSSL ********************************************************************/
36-
void HsOpenSSL_OpenSSL_add_all_algorithms();
36+
void HsOpenSSL_init();
3737
void HsOpenSSL_OPENSSL_free(void* ptr);
3838

3939
/* BIO ************************************************************************/

0 commit comments

Comments
 (0)