packages feed

HsOpenSSL 0.11.7.4 → 0.11.7.5

raw patch · 4 files changed

+38/−6 lines, 4 filessetup-changedPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ OpenSSL.Session: contextSetALPNProtos :: SSLContext -> [ByteString] -> IO ()

Files

ChangeLog view
@@ -1,3 +1,12 @@+2022-02-05  Vladimir Shabanov  <dev@vshabanov.com>++	* HsOpenSSL.cabal (Version): Bump version to 0.11.7.5++	* Better suggestions when OpenSSL is not found (#75)++	* Add contextSetALPNProtos+	by Akshay Mankar @akshaymankar (#76)+ 2022-12-21  Vladimir Shabanov  <dev@vshabanov.com>  	* HsOpenSSL.cabal (Version): Bump version to 0.11.7.4
HsOpenSSL.cabal view
@@ -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.4+Version:       0.11.7.5 License:       PublicDomain License-File:  COPYING Author:        Adam Langley, Mikhail Vorozhtsov, PHO, Taru Karttunen@@ -68,7 +68,7 @@         True  Custom-setup-    setup-depends: Cabal >= 1.12,+    setup-depends: Cabal >= 1.12 && < 4,                    base  >= 4.8 && < 5  Library
OpenSSL/Session.hsc view
@@ -32,6 +32,7 @@   , contextSetCADirectory   , contextGetCAStore   , contextSetSessionIdContext+  , contextSetALPNProtos      -- * SSL connections   , SSL@@ -377,6 +378,19 @@     B.unsafeUseAsCStringLen idCtx $ \(cIdCtx, len) ->         _ssl_set_session_id_context ctx cIdCtx (fromIntegral len) >>= failIf_ (/= 1) +foreign import capi unsafe "openssl/ssl.h SSL_CTX_set_alpn_protos"+  _ssl_set_alpn_protos :: Ptr SSLContext_ -> Ptr CChar -> CUInt -> IO CInt++contextSetALPNProtos :: SSLContext -> [B.ByteString] -> IO ()+contextSetALPNProtos context protos =+  withContext context $ \ctx -> do+    -- Protos need to be wire-format as documented here:+    -- https://www.openssl.org/docs/man1.0.2/man3/SSL_CTX_set_alpn_protos.html#NOTES+    let formattedProtos = B.concat $ map (\p -> B.cons (fromIntegral (B.length p)) p) protos+    B.unsafeUseAsCStringLen formattedProtos $ \(cFormattedProtos, len) ->+      -- This function breaks the convention of returning '1' for success:+      -- https://www.openssl.org/docs/man1.0.2/man3/SSL_CTX_set_alpn_protos.html#RETURN-VALUES+      _ssl_set_alpn_protos ctx cFormattedProtos (fromIntegral len) >>= failIf_ (/= 0)  data {-# CTYPE "openssl/ssl.h" "SSL" #-} SSL_ -- | This is the type of an SSL connection
Setup.hs view
@@ -88,10 +88,19 @@                         fail $ multipleFound fs  notFound = unlines-    [ "Can't find OpenSSL library,"-    , "install it via 'brew install openssl' or 'port install openssl'"-    , "or use --extra-include-dirs= and --extra-lib-dirs="-    , "to specify location of installed OpenSSL library."+    [ "Can't find OpenSSL library."+    , "Install it via 'brew install openssl' or 'port install openssl'."+    , ""+    , "If you already have OpenSSL installed, specify the location"+    , "of the installed library in cabal.project:"+    , ""+    , "package HsOpenSSL"+    , "  extra-include-dirs: ..."+    , "  extra-lib-dirs: ..."+    , ""+    , "or use"+    , ""+    , "cabal configure --extra-include-dirs=... --extra-lib-dirs=..."     ]  multipleFound fs = unlines