soap-openssl (empty) → 0.1.0.0
raw patch · 5 files changed
+110/−0 lines, 5 filesdep +HsOpenSSLdep +basedep +configuratorsetup-changed
Dependencies added: HsOpenSSL, base, configurator, data-default, http-client, http-client-openssl, soap, text
Files
- LICENSE +20/−0
- Setup.hs +2/−0
- changelog +3/−0
- soap-openssl.cabal +40/−0
- src/Network/SOAP/Transport/HTTP/OpenSSL.hs +45/−0
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2013 Alexander Bondarenko++Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions:++The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ changelog view
@@ -0,0 +1,3 @@+0.1:++ + Initial version.
+ soap-openssl.cabal view
@@ -0,0 +1,40 @@+name: soap-openssl+version: 0.1.0.0+synopsis: TLS-enabled SOAP transport (using openssl bindings)+description:+ TLS-enabled SOAP transport (using openssl bindings)+ .+ > main = withOpenSSL $ do+ > -- Initial one-time preparations.+ > settings <- makeSettings (Just ("client.crt", "client.key"))+ > transport <- initTransportWith settings "http://example.com/soap/endpoint" id (iconv "cp-1251")+ >+ > -- the rest is the same as before...++homepage: https://bitbucket.org/dpwiz/haskell-soap+license: MIT+license-file: LICENSE+author: Alexander Bondarenko+maintainer: aenor.realm@gmail.com+-- copyright: +category: Web+build-type: Simple+cabal-version: >=1.10+extra-source-files: + changelog++library+ ghc-options: -Wall+ exposed-modules: Network.SOAP.Transport.HTTP.OpenSSL+ build-depends: base >=4.6 && <5+ , soap >= 0.2.2 && < 0.3+ , http-client >= 0.2 && < 0.3+ , http-client-openssl >= 0.2 && < 0.3+ , HsOpenSSL+ , text+ , configurator+ , data-default++ hs-source-dirs: src+ default-language: Haskell2010+ default-extensions: OverloadedStrings
+ src/Network/SOAP/Transport/HTTP/OpenSSL.hs view
@@ -0,0 +1,45 @@+-- | SSL-enabled http transport with support for https requests and client certificates.++module Network.SOAP.Transport.HTTP.OpenSSL+ ( confTransport+ , makeSettings+ -- * OpenSSL parts+ , withOpenSSL, SSLContext+ ) where++import Network.HTTP.Client (ManagerSettings)+import Network.SOAP.Transport (Transport)+import Network.SOAP.Transport.HTTP (confTransportWith)++import Network.HTTP.Client.OpenSSL+import OpenSSL.Session as SSL++import Data.Text (Text)+import qualified Data.Configurator as Conf+import Data.Configurator.Types (Config)+import Control.Monad (liftM2)++-- | Initialize a SOAP HTTP transport with HTTPS support using tls.+confTransport :: Text -- ^ Section name containing transport settings.+ -> Config+ -> (SSLContext -> IO ())+ -> IO Transport+confTransport section conf updCtx = do+ let get = Conf.lookup (Conf.subconfig section conf)+ cert <- get "client_cert"+ key <- get "client_key"+ settings <- makeSettings (liftM2 (,) cert key) updCtx+ confTransportWith settings section conf id id++makeSettings :: Maybe (FilePath, FilePath) -- ^ Client certificate and key.+ -> (SSLContext -> IO ()) -- ^ Additional OpenSSL setup if needed.+ -> IO ManagerSettings+makeSettings clientCert updateContext = return . opensslManagerSettings $ do+ ctx <- SSL.context+ case clientCert of+ Nothing -> return ()+ Just (certFile, keyFile) -> do+ SSL.contextSetCertificateFile ctx certFile+ SSL.contextSetPrivateKeyFile ctx keyFile+ updateContext ctx+ return ctx