Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package ghc-crypton-x509-store for
openSUSE:Factory checked in at 2026-11-24 12:27:50
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-crypton-x509-store (Old)
and /work/SRC/openSUSE:Factory/.ghc-crypton-x509-store.new.1340718 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-crypton-x509-store"
Tue Nov 24 12:27:50 2026 rev:8 rq:1399137 version:1.10.1
Changes:
--------
---
/work/SRC/openSUSE:Factory/ghc-crypton-x509-store/ghc-crypton-x509-store.changes
2026-11-06 19:54:58.487640725 +0100
+++
/work/SRC/openSUSE:Factory/.ghc-crypton-x509-store.new.1340718/ghc-crypton-x509-store.changes
2026-11-24 12:32:52.091809710 +0100
@@ -1,0 +2,23 @@
+Wed Nov 18 08:15:45 UTC 2026 - Peter Simons <[email protected]>
+
+- Update crypton-x509-store to version 1.10.1.
+ ## 1.10.1
+
+ `TRUSTED CERTIFICATE` PEM blocks are no longer used as trust anchors,
+ and several CAs with the same subject are kept.
+
+ * Fix trust store loading
+ [#38](https://github.com/kazu-yamamoto/crypton-certificate/pull/38)
+ * Build certification paths with backtracking and implement CRL distribution
points
+ [#48](https://github.com/kazu-yamamoto/crypton-certificate/pull/48)
+ * Read store files strictly with cloexec
+ [#49](https://github.com/kazu-yamamoto/crypton-certificate/pull/49)
+
+ ## 1.10.0
+
+ * Read ML-DSA private keys
+ [#35](https://github.com/kazu-yamamoto/crypton-certificate/pull/35)
+ * Follow the breaking change in `crypton-x509` 1.10.0
+ [#35](https://github.com/kazu-yamamoto/crypton-certificate/pull/35)
+
+-------------------------------------------------------------------
Old:
----
crypton-x509-store-1.9.0.tar.gz
crypton-x509-store.cabal
New:
----
crypton-x509-store-1.10.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-crypton-x509-store.spec ++++++
--- /var/tmp/diff_new_pack.UjJWCM/_old 2026-11-24 12:32:53.767880674 +0100
+++ /var/tmp/diff_new_pack.UjJWCM/_new 2026-11-24 12:32:53.771880843 +0100
@@ -1,7 +1,7 @@
#
# spec file for package ghc-crypton-x509-store
#
-# Copyright (c) 2026 SUSE LLC
+# Copyright (c) 2026 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,49 +17,53 @@
%global pkg_name crypton-x509-store
-%global pkgver %{pkg_name}-%{version}
+%bcond_with ghc_prof
%bcond_with tests
-Name: ghc-%{pkg_name}
-Version: 1.9.0
+Name: ghc-%pkg_name
+Version: 1.10.1
Release: 0
+%global pkgver %pkg_name-%{version}
Summary: X.509 collection accessing and storing methods
License: BSD-3-Clause
-URL: https://hackage.haskell.org/package/%{pkg_name}
-Source0:
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
-Source1:
https://hackage.haskell.org/package/%{pkg_name}-%{version}/revision/2.cabal#/%{pkg_name}.cabal
+URL: https://hackage.haskell.org/package/%pkg_name
+Source0:
https://hackage.haskell.org/package/%pkg_name-%{version}/%pkg_name-%{version}.tar.gz
BuildRequires: ghc-Cabal-devel
BuildRequires: ghc-base-devel
-BuildRequires: ghc-base-prof
BuildRequires: ghc-bytestring-devel
-BuildRequires: ghc-bytestring-prof
BuildRequires: ghc-containers-devel
-BuildRequires: ghc-containers-prof
BuildRequires: ghc-crypton-asn1-encoding-devel
-BuildRequires: ghc-crypton-asn1-encoding-prof
BuildRequires: ghc-crypton-asn1-types-devel
-BuildRequires: ghc-crypton-asn1-types-prof
BuildRequires: ghc-crypton-devel
BuildRequires: ghc-crypton-pem-devel
+BuildRequires: ghc-crypton-x509-devel
+BuildRequires: ghc-directory-devel
+BuildRequires: ghc-filepath-devel
+BuildRequires: ghc-mtl-devel
+BuildRequires: ghc-rpm-macros >= 2.9.2
+BuildRequires: ghc-unix-devel
+ExcludeArch: %{ix86}
+%if %{with ghc_prof}
+BuildRequires: ghc-base-prof
+BuildRequires: ghc-bytestring-prof
+BuildRequires: ghc-containers-prof
+BuildRequires: ghc-crypton-asn1-encoding-prof
+BuildRequires: ghc-crypton-asn1-types-prof
BuildRequires: ghc-crypton-pem-prof
BuildRequires: ghc-crypton-prof
-BuildRequires: ghc-crypton-x509-devel
BuildRequires: ghc-crypton-x509-prof
-BuildRequires: ghc-directory-devel
BuildRequires: ghc-directory-prof
-BuildRequires: ghc-filepath-devel
BuildRequires: ghc-filepath-prof
-BuildRequires: ghc-mtl-devel
BuildRequires: ghc-mtl-prof
-BuildRequires: ghc-rpm-macros
-BuildRequires: ghc-unix-devel
BuildRequires: ghc-unix-prof
-ExcludeArch: %{ix86}
+%endif
%if %{with tests}
BuildRequires: ghc-tasty-devel
BuildRequires: ghc-tasty-hunit-devel
+%if %{with ghc_prof}
BuildRequires: ghc-tasty-hunit-prof
BuildRequires: ghc-tasty-prof
%endif
+%endif
%description
X.509 collection accessing and storing methods for certificate, crl, exception
@@ -76,25 +80,27 @@
This package provides the Haskell %{pkg_name} library development
files.
-%package -n ghc-%{pkg_name}-doc
+%package -n ghc-%pkg_name-doc
Summary: Haskell %{pkg_name} library documentation
Requires: ghc-filesystem
BuildArch: noarch
-%description -n ghc-%{pkg_name}-doc
+%description -n ghc-%pkg_name-doc
This package provides the Haskell %{pkg_name} library documentation.
-%package -n ghc-%{pkg_name}-prof
+%if %{with ghc_prof}
+%package -n ghc-%pkg_name-prof
Summary: Haskell %{pkg_name} profiling library
-Requires: ghc-%{pkg_name}-devel = %{version}-%{release}
-Supplements: (ghc-%{pkg_name}-devel and ghc-prof)
+Requires: ghc-%pkg_name-devel = %{version}-%{release}
+Supplements: (ghc-%pkg_name-devel and ghc-prof)
-%description -n ghc-%{pkg_name}-prof
+%description -n ghc-%pkg_name-prof
This package provides the Haskell %{pkg_name} profiling library.
+%endif
+
%prep
-%autosetup -n %{pkg_name}-%{version}
-cp -p %{SOURCE1} %{pkg_name}.cabal
+%autosetup -p1 -n %pkg_name-%{version}
%build
%ghc_lib_build
@@ -117,8 +123,10 @@
%files devel -f %{name}-devel.files
%doc ChangeLog.md
-%files -n ghc-%{pkg_name}-doc -f ghc-%{pkg_name}-doc.files
+%files -n ghc-%pkg_name-doc -f ghc-%pkg_name-doc.files
%license LICENSE
-%files -n ghc-%{pkg_name}-prof -f ghc-%{pkg_name}-prof.files
+%if %{with ghc_prof}
+%files -n ghc-%pkg_name-prof -f ghc-%pkg_name-prof.files
+%endif
++++++ crypton-x509-store-1.9.0.tar.gz -> crypton-x509-store-1.10.1.tar.gz
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/crypton-x509-store-1.9.0/ChangeLog.md
new/crypton-x509-store-1.10.1/ChangeLog.md
--- old/crypton-x509-store-1.9.0/ChangeLog.md 2001-09-09 03:46:40.000000000
+0200
+++ new/crypton-x509-store-1.10.1/ChangeLog.md 2001-09-09 03:46:40.000000000
+0200
@@ -1,5 +1,24 @@
# ChangeLog for crypton-x509-store
+## 1.10.1
+
+`TRUSTED CERTIFICATE` PEM blocks are no longer used as trust anchors,
+and several CAs with the same subject are kept.
+
+* Fix trust store loading
+ [#38](https://github.com/kazu-yamamoto/crypton-certificate/pull/38)
+* Build certification paths with backtracking and implement CRL distribution
points
+ [#48](https://github.com/kazu-yamamoto/crypton-certificate/pull/48)
+* Read store files strictly with cloexec
+ [#49](https://github.com/kazu-yamamoto/crypton-certificate/pull/49)
+
+## 1.10.0
+
+* Read ML-DSA private keys
+ [#35](https://github.com/kazu-yamamoto/crypton-certificate/pull/35)
+* Follow the breaking change in `crypton-x509` 1.10.0
+ [#35](https://github.com/kazu-yamamoto/crypton-certificate/pull/35)
+
## 1.9.0
* Using "ram" instead of "memory"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/crypton-x509-store-1.9.0/Data/X509/CertificateStore.hs
new/crypton-x509-store-1.10.1/Data/X509/CertificateStore.hs
--- old/crypton-x509-store-1.9.0/Data/X509/CertificateStore.hs 2001-09-09
03:46:40.000000000 +0200
+++ new/crypton-x509-store-1.10.1/Data/X509/CertificateStore.hs 2001-09-09
03:46:40.000000000 +0200
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP #-}
+{-# LANGUAGE OverloadedStrings #-}
module Data.X509.CertificateStore (
CertificateStore,
@@ -9,40 +10,46 @@
-- * Queries
findCertificate,
+ findCertificates,
listCertificates,
) where
import Data.Char (isDigit, isHexDigit)
import Data.Either (rights)
-import Data.List (foldl', isPrefixOf)
-#if MIN_VERSION_base(4,9,0)
+import qualified Data.List as L
+#if !(MIN_VERSION_base(4,11,0))
import Data.Semigroup
-#else
-import Data.Monoid
#endif
-import Control.Applicative ((<$>))
import qualified Control.Exception as E
-import Control.Monad (filterM, mplus)
+import Control.Monad (filterM)
import qualified Data.ByteString as B
+import qualified Data.ByteString.Char8 as BC
import qualified Data.Map as M
-import Data.PEM (pemContent, pemParseBS)
+import Data.PEM (PEM, pemContent, pemName, pemParseBS)
import Data.X509
+import Data.X509.ReadFile (readFileCloexec)
import System.Directory (
doesDirectoryExist,
doesFileExist,
getDirectoryContents,
+ pathIsSymbolicLink,
)
-import System.FilePath ((</>))
+import System.FilePath (takeFileName, (</>))
+import qualified System.IO.Error as E
+#if !defined(mingw32_HOST_OS)
+import System.Posix.Files (getFileStatus, isRegularFile)
+#endif
--- | A Collection of certificate or store of certificates.
+-- | A Collection of certificate or store of certificates. Several
+-- certificates may have the same subject, which is compared in its
+-- canonical form.
data CertificateStore
- = CertificateStore (M.Map DistinguishedName SignedCertificate)
+ = CertificateStore (M.Map DistinguishedName [SignedCertificate])
| CertificateStores [CertificateStore]
isEmptyCertificateStore :: CertificateStore -> Bool
isEmptyCertificateStore (CertificateStore m) = M.null m
-isEmptyCertificateStore (CertificateStores []) = True
-isEmptyCertificateStore _ = False
+isEmptyCertificateStore (CertificateStores l) = all isEmptyCertificateStore l
#if MIN_VERSION_base(4,9,0)
instance Semigroup CertificateStore where
@@ -63,21 +70,33 @@
-- | Create a certificate store out of a list of X509 certificate
makeCertificateStore :: [SignedCertificate] -> CertificateStore
-makeCertificateStore = CertificateStore . foldl' accumulate M.empty
+makeCertificateStore = CertificateStore . L.foldl' accumulate M.empty
where
- accumulate m x509 = M.insert (certSubjectDN $ getCertificate x509) x509 m
+ -- the latest certificate comes first
+ accumulate m x509 = M.insertWith add (subjectKey x509) [x509] m
+ add new old = new ++ filter (`notElem` new) old
+ subjectKey = canonicalDistinguishedName . certSubjectDN . getCertificate
--- | Find a certificate using the subject distinguished name
+-- | Find a certificate using the subject distinguished name. If several
+-- certificates have the subject, the one added last is returned.
findCertificate
:: DistinguishedName -> CertificateStore -> Maybe SignedCertificate
-findCertificate dn store = lookupIn store
+findCertificate dn store = case findCertificates dn store of
+ c : _ -> Just c
+ [] -> Nothing
+
+-- | Find all certificates with the subject distinguished name.
+findCertificates
+ :: DistinguishedName -> CertificateStore -> [SignedCertificate]
+findCertificates dn = lookupIn
where
- lookupIn (CertificateStore m) = M.lookup dn m
- lookupIn (CertificateStores l) = foldl mplus Nothing $ map lookupIn l
+ key = canonicalDistinguishedName dn
+ lookupIn (CertificateStore m) = M.findWithDefault [] key m
+ lookupIn (CertificateStores l) = concatMap lookupIn l
-- | List all certificates in a store
listCertificates :: CertificateStore -> [SignedCertificate]
-listCertificates (CertificateStore store) = map snd $ M.toList store
+listCertificates (CertificateStore store) = concat $ M.elems store
listCertificates (CertificateStores l) = concatMap listCertificates l
-- | Create certificate store by reading certificates from file or directory
@@ -104,35 +123,68 @@
-- Try to read certificate from the content of a file.
--
--- The file may contains multiple certificates
+-- The file may contains multiple certificates. Only the PEM blocks
+-- labeled CERTIFICATE are used: a TRUSTED CERTIFICATE block carries
+-- OpenSSL trust settings, which are not interpreted. Broken blocks
+-- are skipped.
readCertificates :: FilePath -> IO [SignedCertificate]
readCertificates file =
- E.catch
- (either (const []) (rights . map getCert) . pemParseBS <$> B.readFile
file)
+ E.catchIOError
+ (rights . map getCert . filter isCert . pemBlocks <$> readFileCloexec
file)
skipIOError
where
+ isCert pem = pemName pem `elem` ["CERTIFICATE", "X509 CERTIFICATE"]
getCert = decodeSignedCertificate . pemContent
skipIOError :: E.IOException -> IO [SignedCertificate]
skipIOError _ = return []
+-- | Parse PEM blocks one by one so that a broken block does not
+-- discard the others.
+pemBlocks :: B.ByteString -> [PEM]
+pemBlocks = go . BC.lines
+ where
+ go ls = case dropWhile (not . B.isPrefixOf "-----BEGIN ") ls of
+ [] -> []
+ begin : rest -> case break (B.isPrefixOf "-----END ") rest of
+ (body, end : rest') ->
+ either (const []) id (pemParseBS $ BC.unlines (begin : body ++
[end]))
+ ++ go rest'
+ _ -> []
+
-- List all the path susceptible to contains a certificate in a directory
--
-- if the parameter is not a directory, hilarity follows.
listDirectoryCerts :: FilePath -> IO [FilePath]
listDirectoryCerts path =
- getDirContents >>= filterM doesFileExist
+ getDirContents >>= filterM keep
where
+ -- hashed names are usually symbolic links to other files in the
+ -- directory, but are regular files on Android, for instance
+ keep p = do
+ regular <- isRegular p
+ if regular && isHashedFile (takeFileName p)
+ then not <$> pathIsSymbolicLink p
+ else return regular
isHashedFile s =
length s == 10
&& isDigit (s !! 9)
&& (s !! 8) == '.'
&& all isHexDigit (take 8 s)
- isCert x = (not $ isPrefixOf "." x) && (not $ isHashedFile x)
+ isCert x = not $ L.isPrefixOf "." x
getDirContents =
- E.catch
+ E.catchIOError
(map (path </>) . filter isCert <$> getDirectoryContents path)
emptyPaths
where
emptyPaths :: E.IOException -> IO [FilePath]
emptyPaths _ = return []
+
+-- | Whether the path is a regular file, following symbolic links.
+isRegular :: FilePath -> IO Bool
+#if defined(mingw32_HOST_OS)
+isRegular = doesFileExist
+#else
+isRegular p =
+ E.catchIOError (isRegularFile <$> getFileStatus p) (\_ -> return False)
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/crypton-x509-store-1.9.0/Data/X509/File.hs
new/crypton-x509-store-1.10.1/Data/X509/File.hs
--- old/crypton-x509-store-1.9.0/Data/X509/File.hs 2001-09-09
03:46:40.000000000 +0200
+++ new/crypton-x509-store-1.10.1/Data/X509/File.hs 2001-09-09
03:46:40.000000000 +0200
@@ -1,45 +1,27 @@
-{-# LANGUAGE CPP #-}
-
module Data.X509.File (
readSignedObject,
readKeyFile,
PEMError (..),
) where
-#ifndef MIN_VERSION_unix
-#define MIN_VERSION_unix(x, y, z) 0
-#endif
-
-import Control.Applicative
-import Control.Exception (Exception (..), throw)
-import Data.ASN1.BinaryEncoding
-import Data.ASN1.Encoding
+import qualified Control.Exception as E
import Data.ASN1.Types
-import qualified Data.ByteString.Lazy as L
import Data.Maybe
-import Data.PEM (PEM, pemContent, pemName, pemParseLBS)
+import Data.PEM (PEM, pemContent, pemParseBS)
import qualified Data.X509 as X509
import Data.X509.Memory (pemToKey)
-#if defined(MIN_VERSION_unix) && MIN_VERSION_unix(2,8,0)
-import System.Posix.IO
-#endif
+import Data.X509.ReadFile (readFileCloexec)
newtype PEMError = PEMError {displayPEMError :: String}
deriving (Show)
-instance Exception PEMError where
+instance E.Exception PEMError where
displayException = displayPEMError
readPEMs :: FilePath -> IO [PEM]
readPEMs filepath = do
-#if defined(MIN_VERSION_unix) && MIN_VERSION_unix(2,8,0)
- fd <- openFd filepath ReadOnly defaultFileFlags{cloexec = True}
- h <- fdToHandle fd
- content <- L.hGetContents h
-#else
- content <- L.readFile filepath
-#endif
- either (throw . PEMError) pure $ pemParseLBS content
+ content <- readFileCloexec filepath
+ either (E.throwIO . PEMError) pure $ pemParseBS content
-- | return all the signed objects in a file.
--
@@ -55,4 +37,4 @@
-- | return all the private keys that were successfully read from a file.
readKeyFile :: FilePath -> IO [X509.PrivKey]
-readKeyFile path = catMaybes . foldl pemToKey [] <$> readPEMs path
+readKeyFile path = catMaybes . concatMap (pemToKey []) <$> readPEMs path
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/crypton-x509-store-1.9.0/Data/X509/Memory.hs
new/crypton-x509-store-1.10.1/Data/X509/Memory.hs
--- old/crypton-x509-store-1.9.0/Data/X509/Memory.hs 2001-09-09
03:46:40.000000000 +0200
+++ new/crypton-x509-store-1.10.1/Data/X509/Memory.hs 2001-09-09
03:46:40.000000000 +0200
@@ -27,7 +27,7 @@
import Data.X509.EC as X509
readKeyFileFromMemory :: B.ByteString -> [X509.PrivKey]
-readKeyFileFromMemory = either (const []) (catMaybes . foldl pemToKey []) .
pemParseBS
+readKeyFileFromMemory = either (const []) (catMaybes . concatMap (pemToKey
[])) . pemParseBS
readSignedObjectFromMemory
:: (ASN1Object a, Eq a, Show a)
@@ -76,6 +76,9 @@
Right (k@(X509.PrivKeyX448 _), _) -> Just k
Right (k@(X509.PrivKeyEd25519 _), _) -> Just k
Right (k@(X509.PrivKeyEd448 _), _) -> Just k
+ Right (k@(X509.PrivKeyMLDSA44 _), _) -> Just k
+ Right (k@(X509.PrivKeyMLDSA65 _), _) -> Just k
+ Right (k@(X509.PrivKeyMLDSA87 _), _) -> Just k
_ -> Nothing
dsaFromASN1 :: [ASN1] -> Either String (DSA.KeyPair, [ASN1])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/crypton-x509-store-1.9.0/Data/X509/ReadFile.hs
new/crypton-x509-store-1.10.1/Data/X509/ReadFile.hs
--- old/crypton-x509-store-1.9.0/Data/X509/ReadFile.hs 1970-01-01
01:00:00.000000000 +0100
+++ new/crypton-x509-store-1.10.1/Data/X509/ReadFile.hs 2001-09-09
03:46:40.000000000 +0200
@@ -0,0 +1,29 @@
+{-# LANGUAGE CPP #-}
+
+module Data.X509.ReadFile (
+ readFileCloexec,
+) where
+
+#ifndef MIN_VERSION_unix
+#define MIN_VERSION_unix(x, y, z) 0
+#endif
+
+import qualified Data.ByteString as B
+#if defined(MIN_VERSION_unix) && MIN_VERSION_unix(2,8,0)
+import qualified Control.Exception as E
+import System.IO (hClose)
+import System.Posix.IO
+#endif
+
+-- | Read a whole file strictly. The file descriptor is not inherited
+-- by child processes (when unix >= 2.8 is available).
+readFileCloexec :: FilePath -> IO B.ByteString
+#if defined(MIN_VERSION_unix) && MIN_VERSION_unix(2,8,0)
+readFileCloexec path =
+ E.bracket
+ (openFd path ReadOnly defaultFileFlags{cloexec = True} >>= fdToHandle)
+ hClose
+ B.hGetContents
+#else
+readFileCloexec = B.readFile
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/crypton-x509-store-1.9.0/Tests/Tests.hs
new/crypton-x509-store-1.10.1/Tests/Tests.hs
--- old/crypton-x509-store-1.9.0/Tests/Tests.hs 2001-09-09 03:46:40.000000000
+0200
+++ new/crypton-x509-store-1.10.1/Tests/Tests.hs 2001-09-09
03:46:40.000000000 +0200
@@ -1,10 +1,19 @@
-- | x509-store test suite.
module Main (main) where
+import Control.Exception (bracket_)
+import Data.ASN1.Types (ASN1StringEncoding (..), asn1CharacterString)
import qualified Data.ByteString as B
+import qualified Data.ByteString.Char8 as BC
+import Data.Maybe (isJust, isNothing)
import Data.String (fromString)
import Data.X509
+import Data.X509.CertificateStore
+import Data.X509.File
import Data.X509.Memory
+import System.Directory
+import System.FilePath ((</>))
+import System.Info (os)
import Test.Tasty
import Test.Tasty.HUnit
@@ -390,6 +399,92 @@
readSignedCertificateFromMemory :: B.ByteString -> [SignedCertificate]
readSignedCertificateFromMemory = readSignedObjectFromMemory
+keyOrderTest :: TestTree
+keyOrderTest =
+ testCase "Key order" $
+ map kind (readKeyFileFromMemory (rsaKey2 <> ed25519Key2 <> dsaKey2))
+ @?= ["RSA", "Ed25519", "DSA"]
+
+kind :: PrivKey -> String
+kind PrivKeyRSA{} = "RSA"
+kind PrivKeyEd25519{} = "Ed25519"
+kind PrivKeyDSA{} = "DSA"
+kind _ = "other"
+
+-- | Runs an action in a fresh temporary directory.
+withTempDir :: (FilePath -> IO a) -> IO a
+withTempDir f = do
+ tmp <- getTemporaryDirectory
+ let dir = tmp </> "crypton-x509-store-test"
+ removePathForcibly dir
+ bracket_ (createDirectory dir) (removePathForcibly dir) (f dir)
+
+storeTests :: TestTree
+storeTests =
+ testGroup
+ "CertificateStore"
+ [ testCase "TRUSTED CERTIFICATE is skipped" $ withTempDir $ \dir -> do
+ let file = dir </> "bundle.crt"
+ B.writeFile file $ relabel rsaCertificate <> dsaCertificate
+ certs <- readCertificates file
+ length certs @?= 1
+ , testCase "broken PEM block is skipped" $ withTempDir $ \dir -> do
+ let file = dir </> "bundle.pem"
+ B.writeFile file $ rsaCertificate <> broken <> dsaCertificate
+ certs <- readCertificates file
+ length certs @?= 2
+ , testCase "hashed regular file is read" $ withTempDir $ \dir -> do
+ B.writeFile (dir </> "00673b5b.0") rsaCertificate
+ store <- readCertificateStore dir
+ assertBool "empty store" $ isJust store
+ , testCase "hashed symbolic link is skipped" $
+ if os == "mingw32"
+ then return ()
+ else withTempDir $ \dir -> do
+ let sub = dir </> "certs"
+ createDirectory sub
+ B.writeFile (dir </> "target.pem") rsaCertificate
+ createFileLink (dir </> "target.pem") (sub </>
"00673b5b.0")
+ store <- readCertificateStore sub
+ assertBool "non-empty store" $ isNothing store
+ , testCase "certificates with the same subject" $ do
+ -- both certificates have CN=Test
+ let certs = readSignedObjectFromMemory (rsaCertificate <>
dsaCertificate)
+ store = makeCertificateStore certs
+ subject = certSubjectDN $ getCertificate $ last certs
+ length (findCertificates subject store) @?= 2
+ length (listCertificates store) @?= 2
+ findCertificate subject store @?= Just (last certs)
+ , testCase "subjects are compared in canonical form" $ do
+ let store = makeCertificateStore $ readSignedObjectFromMemory
rsaCertificate
+ dn = DistinguishedName [([2, 5, 4, 3], asn1CharacterString
Printable " TEST ")]
+ assertBool "not found" $ isJust $ findCertificate dn store
+ , testCase "key file order" $ withTempDir $ \dir -> do
+ let file = dir </> "keys.pem"
+ B.writeFile file $ rsaKey2 <> ed25519Key2 <> dsaKey2
+ keys <- readKeyFile file
+ map kind keys @?= ["RSA", "Ed25519", "DSA"]
+ , testCase "signed object file" $ withTempDir $ \dir -> do
+ let file = dir </> "cert.pem"
+ B.writeFile file rsaCertificate
+ certs <- readSignedObject file :: IO [SignedCertificate]
+ length certs @?= 1
+ , testCase "composed empty store is empty" $
+ assertBool "not empty" $
+ isEmptyCertificateStore (mempty <> mempty)
+ ]
+ where
+ relabel = BC.pack . replace "CERTIFICATE-----" "TRUSTED CERTIFICATE-----"
. BC.unpack
+ replace old new str@(c : cs)
+ | take (length old) str == old = new ++ replace old new (drop (length
old) str)
+ | otherwise = c : replace old new cs
+ replace _ _ [] = []
+ broken =
+ fromString $
+ "-----BEGIN CERTIFICATE-----\n"
+ ++ "abc\n"
+ ++ "-----END CERTIFICATE-----\n"
+
-- | Runs the test suite.
main :: IO ()
main =
@@ -400,5 +495,7 @@
"Memory"
[ memoryKeyTests
, memoryCertificateTests
+ , keyOrderTest
]
+ , storeTests
]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/crypton-x509-store-1.9.0/crypton-x509-store.cabal
new/crypton-x509-store-1.10.1/crypton-x509-store.cabal
--- old/crypton-x509-store-1.9.0/crypton-x509-store.cabal 2001-09-09
03:46:40.000000000 +0200
+++ new/crypton-x509-store-1.10.1/crypton-x509-store.cabal 2001-09-09
03:46:40.000000000 +0200
@@ -1,6 +1,6 @@
cabal-version: >=1.10
name: crypton-x509-store
-version: 1.9.0
+version: 1.10.1
license: BSD3
license-file: LICENSE
copyright: Vincent Hanquez <[email protected]>
@@ -19,7 +19,7 @@
source-repository head
type: git
location: https://github.com/kazu-yamamoto/crypton-certificate
- subdir: x509-store
+ subdir: crypton-x509-store
library
exposed-modules:
@@ -27,17 +27,18 @@
Data.X509.File
Data.X509.Memory
+ other-modules: Data.X509.ReadFile
default-language: Haskell2010
ghc-options: -Wall
build-depends:
base >=3 && <5,
bytestring,
containers,
- crypton >=1.1.0 && < 1.2,
+ crypton >=1.1.0 && <2.3,
crypton-asn1-encoding >=0.10.0 && <0.11,
crypton-asn1-types >=0.4.1 && <0.5,
crypton-pem >=0.2.4 && <0.4,
- crypton-x509 >=1.9.0 && <1.10,
+ crypton-x509 >=1.10.3 && <1.11,
directory,
filepath,
mtl
@@ -57,4 +58,7 @@
tasty,
tasty-hunit,
crypton-x509,
- crypton-x509-store
+ crypton-asn1-types,
+ crypton-x509-store,
+ directory,
+ filepath