packages feed

soap-tls 0.1.0.0 → 0.1.1.0

raw patch · 3 files changed

+36/−6 lines, 3 filesdep +http-clientdep +x509dep +x509-store

Dependencies added: http-client, x509, x509-store

Files

changelog view
@@ -1,3 +1,8 @@+0.1.1:++  + Server certificate validator can be specified for confTransport.+  * Re-export default validator from X509.+ 0.1:    + Initial version.
soap-tls.cabal view
@@ -1,5 +1,5 @@ name:                soap-tls-version:             0.1.0.0+version:             0.1.1.0 synopsis:            TLS-enabled SOAP transport (using tls package) description:         TLS-enabled SOAP transport (using tls package) homepage:            https://bitbucket.org/dpwiz/haskell-soap@@ -19,9 +19,12 @@   exposed-modules:     Network.SOAP.Transport.HTTP.TLS   build-depends:       base >=4.6 && <5                      , soap >= 0.2.2 && < 0.3+                     , http-client >= 0.2 && < 0.3                      , http-client-tls >= 0.2 && < 0.3                      , tls >= 1.2 && < 2                      , connection >= 0.2 && < 0.3+                     , x509+                     , x509-store                      , x509-validation                      , text                      , configurator
src/Network/SOAP/Transport/HTTP/TLS.hs view
@@ -1,13 +1,21 @@ -- | SSL-enabled http transport with support for https requests and client certificates. -module Network.SOAP.Transport.HTTP.TLS where+module Network.SOAP.Transport.HTTP.TLS+    ( confTransport+    , makeSettings+    -- * Certificate validation+    , ServerCertCallback, validateDefault+    ) where +import Network.HTTP.Client (ManagerSettings) import Network.SOAP.Transport (Transport) import Network.SOAP.Transport.HTTP (confTransportWith)  import Network.HTTP.Client.TLS import Network.TLS-import Data.X509.Validation as X509+import Data.X509+import Data.X509.CertificateStore+import Data.X509.Validation import Network.Connection (TLSSettings(..))  import           Data.Monoid@@ -16,13 +24,27 @@ import qualified Data.Configurator as Conf import           Data.Configurator.Types (Config) -confTransport :: Text -> Config -> IO Transport-confTransport section conf = do+type ServerCertCallback = CertificateStore+                       -> ValidationCache+                       -> ServiceID+                       -> CertificateChain+                       -> IO [FailedReason]++-- | Initialize a SOAP HTTP transport with HTTPS support using tls.+confTransport :: Text   -- ^ Section name containing transport settings.+              -> Config+              -> ServerCertCallback+              -> IO Transport+confTransport section conf onSC = do     cert <- Conf.lookup conf (section <> ".client_cert")     key <- Conf.lookup conf (section <> ".client_key")-    settings <- makeSettings cert key X509.validateDefault+    settings <- makeSettings cert key onSC     confTransportWith settings section conf id id +makeSettings :: Maybe FilePath+             -> Maybe FilePath+             -> ServerCertCallback+             -> IO ManagerSettings makeSettings (Just certFile) (Just keyFile) onSC = do     creds <- either error Just `fmap` credentialLoadX509 certFile keyFile