packages feed

tls-extra 0.4.3 → 0.4.4

raw patch · 4 files changed

+30/−17 lines, 4 filesdep ~certificatePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: certificate

API changes (from Hackage documentation)

Files

Examples/RetrieveCertificate.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE ScopedTypeVariables, DeriveDataTypeable #-}+{-# LANGUAGE ScopedTypeVariables, DeriveDataTypeable, ViewPatterns #-}  import Network.TLS import Network.TLS.Extra@@ -6,6 +6,7 @@ import Data.Char import Data.IORef import Data.Time.Clock+import Data.Certificate.X509  import System.IO import Control.Monad@@ -47,7 +48,7 @@ 	{ destination = "localhost" &= help "destination address to connect to" &= typ "address" 	, port        = "443"       &= help "destination port to connect to" &= typ "port" 	, chain       = False       &= help "also output the chain of certificate used"-	, output      = "pem"       &= help "define the format of output (PEM by default)" &= typ "format"+	, output      = "simple"    &= help "define the format of output (full, pem, default: simple)" &= typ "format" 	, verify      = False       &= help "verify the chain received with the trusted system certificates" 	, verifyFQDN  = ""          &= help "verify the chain against a specific fully qualified domain name (e.g. web.example.com)" &= explicit &= name "verify-domain-name" 	} &= summary "RetrieveCertificate remotely for SSL/TLS protocol"@@ -55,8 +56,13 @@ 		[ "Retrieve the remote certificate and optionally its chain from a remote destination" 		] -showCert _ cert =-	putStrLn $ show cert+showCert "full" cert = putStrLn $ show cert++showCert _ (x509Cert -> cert)  = do+	putStrLn ("serial:   " ++ (show $ certSerial cert))+	putStrLn ("issuer:   " ++ (show $ certIssuerDN cert))+	putStrLn ("subject:  " ++ (show $ certSubjectDN cert))+	putStrLn ("validity: " ++ (show $ fst $ certValidity cert) ++ " to " ++ (show $ snd $ certValidity cert))  main = do 	a <- cmdArgs progArgs
Examples/Stunnel.hs view
@@ -282,5 +282,5 @@ main = do 	x <- cmdArgsRun mode 	case x of-		Client _ _ _ _ _ _ -> doClient x-		Server _ _ _ _ _ _ _ _ -> doServer x+		Client {} -> doClient x+		Server {} -> doServer x
Network/TLS/Extra/Certificate.hs view
@@ -33,14 +33,20 @@  import Data.Time.Calendar import Data.List (find)+import Data.Maybe (fromMaybe) --- | combine many certificates checking function together.--- if one check fail, the whole sequence of checking is cuted short and return the--- reject reason.+#if defined(NOCERTVERIFY)++import System.IO (hPutStrLn, stderr)++#endif++-- | Returns 'CertificateUsageAccept' if all the checks pass, or the first +--   failure. certificateChecks :: [ [X509] -> IO TLSCertificateUsage ] -> [X509] -> IO TLSCertificateUsage certificateChecks checks x509s = do-	r <- sequence $ map (\c -> c x509s) checks-	return $ maybe CertificateUsageAccept id $ find ((/=) CertificateUsageAccept) r+	r <- mapM (\c -> c x509s) checks+	return $ fromMaybe CertificateUsageAccept $ find (CertificateUsageAccept /=) r  #if defined(NOCERTVERIFY) @@ -52,8 +58,8 @@  - for now, print a big fat warning (better than nothing) and returns true  -} certificateVerifyChain_ :: [X509] -> IO TLSCertificateUsage certificateVerifyChain_ _ = do-	putStrLn "****************** certificate verify chain doesn't yet work on your platform **********************"-	putStrLn "please consider contributing to the certificate package to fix this issue"+	hPutStrLn stderr "****************** certificate verify chain doesn't yet work on your platform **********************"+	hPutStrLn stderr "please consider contributing to the certificate package to fix this issue" 	return CertificateUsageAccept  #else@@ -113,7 +119,7 @@ 		esig  = B.pack sig 		pk    = certPubKey scert --- | returns if this certificate is self signed.+-- | Is this certificate self signed? certificateSelfSigned :: X509 -> Bool certificateSelfSigned x509 = certMatchDN x509 x509 
tls-extra.cabal view
@@ -1,5 +1,5 @@ Name:                tls-extra-Version:             0.4.3+Version:             0.4.4 Description:    a set of extra definitions, default values and helpers for tls. License:             BSD3@@ -36,7 +36,7 @@                    , vector                    , crypto-api >= 0.5                    , cryptocipher >= 0.3.0-                   , certificate >= 1.1.0 && < 1.2.0+                   , certificate >= 1.1.1 && < 1.2.0                    , text >= 0.5 && < 1.0                    , time   Exposed-modules:   Network.TLS.Extra@@ -46,7 +46,7 @@                      Network.TLS.Extra.Connection                      Network.TLS.Extra.Thread   ghc-options:       -Wall -fno-warn-missing-signatures-  if os(windows) || os(osx)+  if os(windows)     cpp-options:     -DNOCERTVERIFY  Executable           stunnel@@ -101,6 +101,7 @@                    , HUnit                    , QuickCheck >= 2                    , bytestring+                   , cprng-aes >= 0.2.3   else     Buildable:       False