warp-tls-simple 0.1.0.2 → 0.1.1.0
raw patch · 2 files changed
+33/−40 lines, 2 filesdep −reludedep −textPVP ok
version bump matches the API change (PVP)
Dependencies removed: relude, text
API changes (from Hackage documentation)
Files
src/Network/Wai/Handler/WarpTLS/Simple.hs view
@@ -67,6 +67,7 @@ tlsConfigParser, ) where +import Data.List (intercalate) import Network.Wai (Application) import Network.Wai.Handler.Warp qualified as Warp import Network.Wai.Handler.WarpTLS qualified as WarpTLS@@ -192,7 +193,7 @@ {- | Ensure TLS certificates exist for auto-generation mode Returns TLSSettings configured with the certificate and key file paths -}-ensureTLSSettings :: FilePath -> Text -> IO WarpTLS.TLSSettings+ensureTLSSettings :: FilePath -> String -> IO WarpTLS.TLSSettings ensureTLSSettings certDir hostArg = do let (certPath, keyPath) = certPaths certDir @@ -201,9 +202,9 @@ if certExists && keyExists then do- putTextLn $ "Using existing TLS certificates from " <> toText certDir <> "/"+ putStrLn $ "Using existing TLS certificates from " ++ certDir ++ "/" else do- putTextLn "Generating TLS certificates for HTTPS support..."+ putStrLn "Generating TLS certificates for HTTPS support..." createDirectoryIfMissing True certDir generateCertificates certDir hostArg @@ -220,19 +221,19 @@ data CertificateRequest = CertificateRequest { certSubject :: CertSubject , certValidityDays :: Int- , certSANHosts :: [Text] -- Additional SAN hostnames- , certSANIPs :: [Text] -- Additional SAN IP addresses+ , certSANHosts :: [String] -- Additional SAN hostnames+ , certSANIPs :: [String] -- Additional SAN IP addresses } deriving stock (Show) -- | Certificate subject information for self-signed certificates data CertSubject = CertSubject- { certCountry :: Text- , certState :: Text- , certLocality :: Text- , certOrganization :: Text- , certOrganizationalUnit :: Text- , certCommonName :: Text+ { certCountry :: String+ , certState :: String+ , certLocality :: String+ , certOrganization :: String+ , certOrganizationalUnit :: String+ , certCommonName :: String } deriving stock (Show) @@ -249,7 +250,7 @@ } -- | Default certificate request for local development-defaultCertRequest :: Text -> CertificateRequest+defaultCertRequest :: String -> CertificateRequest defaultCertRequest hostArg = CertificateRequest { certSubject = defaultCertSubject@@ -282,7 +283,7 @@ let opensslConfig = generateOpenSSLConfig request configPath = certDir <> "/openssl.conf" - writeFileText configPath opensslConfig+ writeFile configPath opensslConfig -- Generate self-signed certificate callProcess@@ -300,27 +301,27 @@ , configPath ] - putTextLn "Generated TLS certificates:"- putTextLn $ " Certificate: " <> toText certPath- putTextLn $ " Private key: " <> toText keyPath- let hostList = intercalate ", " (map toString request.certSANHosts)- putTextLn $ " Valid for: " <> toText hostList <> " and common local network IPs"+ putStrLn "Generated TLS certificates:"+ putStrLn $ " Certificate: " ++ certPath+ putStrLn $ " Private key: " ++ keyPath+ let hostList = intercalate ", " request.certSANHosts+ putStrLn $ " Valid for: " ++ hostList ++ " and common local network IPs" -- | Generate OpenSSL configuration from a certificate request-generateOpenSSLConfig :: CertificateRequest -> Text+generateOpenSSLConfig :: CertificateRequest -> String generateOpenSSLConfig request = let subject = request.certSubject dnsEntries = zipWith- (\i host -> "DNS." <> Prelude.show i <> " = " <> host)+ (\i host -> "DNS." ++ Prelude.show i ++ " = " ++ host) [(1 :: Int) ..] request.certSANHosts ipEntries = zipWith- (\i ip -> "IP." <> Prelude.show i <> " = " <> ip)+ (\i ip -> "IP." ++ Prelude.show i ++ " = " ++ ip) [(length request.certSANHosts + 1 :: Int) ..] request.certSANIPs- allSANEntries = dnsEntries <> ipEntries+ allSANEntries = dnsEntries ++ ipEntries altNamesSection = unlines $ "[alt_names]" : allSANEntries in unlines [ "[req]"@@ -329,12 +330,12 @@ , "prompt = no" , "" , "[req_distinguished_name]"- , "C = " <> subject.certCountry- , "ST = " <> subject.certState- , "L = " <> subject.certLocality- , "O = " <> subject.certOrganization- , "OU = " <> subject.certOrganizationalUnit- , "CN = " <> subject.certCommonName+ , "C = " ++ subject.certCountry+ , "ST = " ++ subject.certState+ , "L = " ++ subject.certLocality+ , "O = " ++ subject.certOrganization+ , "OU = " ++ subject.certOrganizationalUnit+ , "CN = " ++ subject.certCommonName , "" , "[v3_req]" , "basicConstraints = CA:FALSE"@@ -346,7 +347,7 @@ ] -- | Generate self-signed certificates with proper SAN for local network access (simplified API)-generateCertificates :: FilePath -> Text -> IO ()+generateCertificates :: FilePath -> String -> IO () generateCertificates certDir hostArg = generateCertificateWithRequest certDir (defaultCertRequest hostArg)
warp-tls-simple.cabal view
@@ -1,11 +1,11 @@-cabal-version: 2.0+cabal-version: 1.12 -- This file has been generated from package.yaml by hpack version 0.37.0. -- -- see: https://github.com/sol/hpack name: warp-tls-simple-version: 0.1.0.2+version: 0.1.1.0 synopsis: Simple TLS configuration for Warp description: Simplified TLS setup and certificate generation for Warp servers category: Web@@ -22,8 +22,6 @@ Network.Wai.Handler.WarpTLS.Simple other-modules: Paths_warp_tls_simple- autogen-modules:- Paths_warp_tls_simple hs-source-dirs: src default-extensions:@@ -52,21 +50,15 @@ TypeOperators TypeSynonymInstances ViewPatterns- ghc-options: -Wall -optP-Wno-nonportable-include-path -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-deriving-strategies -Wunused-foralls -fprint-explicit-foralls -fprint-explicit-kinds+ ghc-options: -Wall -optP-Wno-nonportable-include-path -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-deriving-strategies -Wunused-foralls -Wunused-packages -fprint-explicit-foralls -fprint-explicit-kinds build-depends: base ==4.* , directory , filepath , optparse-applicative , process- , relude >=1.0- , text , wai , warp , warp-tls , which- mixins:- base hiding (Prelude)- , relude (Relude as Prelude, Relude.Container.One)- , relude default-language: GHC2021