show count of how often a cert has been temporarily trusted
[diohsc.git] / Fingerprint.hs
blob7005a8b257e9b59a61d6e89059e79c6da32fb2cd
1 -- This file is part of Diohsc
2 -- Copyright (C) 2020 Martin Bays <mbays@sdf.org>
3 --
4 -- This program is free software: you can redistribute it and/or modify
5 -- it under the terms of version 3 of the GNU General Public License as
6 -- published by the Free Software Foundation, or any later version.
7 --
8 -- You should have received a copy of the GNU General Public License
9 -- along with this program. If not, see http://www.gnu.org/licenses/.
11 -- | Stupid module to avoid orphan instances, redefining Fingerprint from
12 -- x509-validation to have an Ord instance.
13 module Fingerprint (Fingerprint(..), fingerprint) where
15 import Data.ASN1.Types (ASN1Object)
17 import qualified Data.ByteString as BS
18 import qualified Data.X509 as X
19 import qualified Data.X509.Validation as X
21 newtype Fingerprint = Fingerprint BS.ByteString
22 deriving (Eq,Ord,Show)
24 getFingerprint :: (Show a, Eq a, ASN1Object a) => X.SignedExact a -> X.HashALG -> Fingerprint
25 getFingerprint s a = let X.Fingerprint fp = X.getFingerprint s a in Fingerprint fp
27 fingerprint :: X.SignedCertificate -> Fingerprint
28 fingerprint = (`getFingerprint` X.HashSHA256)