module Crypto.Store.PEM
( readPEMs
, writePEMs
, pemsWriteBS
, pemsWriteLBS
, module Data.PEM
) where
import Data.PEM
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as L
readPEMs :: FilePath -> IO [PEM]
readPEMs :: FilePath -> IO [PEM]
readPEMs FilePath
filepath = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. HasCallStack => FilePath -> a
error forall a. a -> a
id forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Either FilePath [PEM]
pemParseLBS forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FilePath -> IO ByteString
L.readFile FilePath
filepath
pemsWriteBS :: [PEM] -> B.ByteString
pemsWriteBS :: [PEM] -> ByteString
pemsWriteBS = ByteString -> ByteString
L.toStrict forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PEM] -> ByteString
pemsWriteLBS
pemsWriteLBS :: [PEM] -> L.ByteString
pemsWriteLBS :: [PEM] -> ByteString
pemsWriteLBS = [ByteString] -> ByteString
L.concat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map PEM -> ByteString
pemWriteLBS
writePEMs :: FilePath -> [PEM] -> IO ()
writePEMs :: FilePath -> [PEM] -> IO ()
writePEMs FilePath
filepath = FilePath -> ByteString -> IO ()
L.writeFile FilePath
filepath forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PEM] -> ByteString
pemsWriteLBS