diff --git a/Data/X509/CRL.hs b/Data/X509/CRL.hs
--- a/Data/X509/CRL.hs
+++ b/Data/X509/CRL.hs
@@ -17,9 +17,8 @@
     ) where
 
 import Control.Applicative
-import Control.Monad.Error
 
-import Data.Time.Clock (UTCTime)
+import Data.Hourglass (DateTime)
 import Data.ASN1.Types
 
 import Data.X509.DistinguishedName
@@ -32,8 +31,8 @@
     { crlVersion             :: Integer
     , crlSignatureAlg        :: SignatureALG
     , crlIssuer              :: DistinguishedName
-    , crlThisUpdate          :: UTCTime
-    , crlNextUpdate          :: Maybe UTCTime
+    , crlThisUpdate          :: DateTime
+    , crlNextUpdate          :: Maybe DateTime
     , crlRevokedCertificates :: [RevokedCertificate]
     , crlExtensions          :: Extensions
     } deriving (Show,Eq)
@@ -41,7 +40,7 @@
 -- | Describe a revoked certificate identifiable by serial number.
 data RevokedCertificate = RevokedCertificate
     { revokedSerialNumber :: Integer
-    , revokedDate         :: UTCTime
+    , revokedDate         :: DateTime
     , revokedExtensions   :: Extensions
     } deriving (Show,Eq)
 
diff --git a/Data/X509/Cert.hs b/Data/X509/Cert.hs
--- a/Data/X509/Cert.hs
+++ b/Data/X509/Cert.hs
@@ -12,9 +12,8 @@
 module Data.X509.Cert (Certificate(..)) where
 
 import Data.ASN1.Types
-import Data.Time.Clock (UTCTime)
+import Data.Hourglass (DateTime)
 import Control.Applicative ((<$>), (<*>))
-import Control.Monad.Error
 import Data.X509.Internal
 import Data.X509.PublicKey
 import Data.X509.AlgorithmIdentifier
@@ -42,7 +41,7 @@
         , certSerial       :: Integer                -- ^ Serial number
         , certSignatureAlg :: SignatureALG           -- ^ Signature algorithm
         , certIssuerDN     :: DistinguishedName      -- ^ Issuer DN
-        , certValidity     :: (UTCTime, UTCTime)     -- ^ Validity period
+        , certValidity     :: (DateTime, DateTime)   -- ^ Validity period
         , certSubjectDN    :: DistinguishedName      -- ^ Subject DN
         , certPubKey       :: PubKey                 -- ^ Public key
         , certExtensions   :: Extensions             -- ^ Extensions
@@ -65,7 +64,7 @@
         IntVal v -> return v
         _        -> throwError ("missing serial" ++ show n)
 
-parseCertHeaderValidity :: ParseASN1 (UTCTime, UTCTime)
+parseCertHeaderValidity :: ParseASN1 (DateTime, DateTime)
 parseCertHeaderValidity = getNextContainer Sequence >>= toTimeBound
   where toTimeBound [ ASN1Time _ t1 _, ASN1Time _ t2 _ ] = return (t1,t2)
         toTimeBound _                                    = throwError "bad validity format"
diff --git a/Data/X509/DistinguishedName.hs b/Data/X509/DistinguishedName.hs
--- a/Data/X509/DistinguishedName.hs
+++ b/Data/X509/DistinguishedName.hs
@@ -19,7 +19,6 @@
 import Data.Monoid
 import Data.ASN1.Types
 import Data.X509.Internal
-import Control.Monad.Error
 
 -- | A list of OID and strings.
 newtype DistinguishedName = DistinguishedName { getDistinguishedElements :: [(OID, ASN1CharacterString)] }
diff --git a/Data/X509/Ext.hs b/Data/X509/Ext.hs
--- a/Data/X509/Ext.hs
+++ b/Data/X509/Ext.hs
@@ -39,8 +39,8 @@
 import Data.List (find)
 import Data.X509.ExtensionRaw
 import Data.X509.DistinguishedName
+import Data.X509.Internal
 import Control.Applicative
-import Control.Monad.Error
 
 -- | key usage flag that is found in the key usage extension field.
 data ExtKeyUsageFlag =
diff --git a/Data/X509/Internal.hs b/Data/X509/Internal.hs
--- a/Data/X509/Internal.hs
+++ b/Data/X509/Internal.hs
@@ -5,14 +5,30 @@
 -- Stability   : experimental
 -- Portability : unknown
 --
+{-# LANGUAGE CPP #-}
 module Data.X509.Internal
     ( module Data.ASN1.Parse
     , asn1Container
     , OID
+    -- * error handling
+    , ErrT
+    , runErrT
+    , throwError
     ) where
 
 import Data.ASN1.Types
 import Data.ASN1.Parse
+
+#if MIN_VERSION_mtl(2,2,1)
+import Control.Monad.Except
+runErrT :: ExceptT e m a -> m (Either e a)
+runErrT = runExceptT
+type ErrT = ExceptT
+#else
+import Control.Monad.Error
+runErrT = runErrorT
+type ErrT = ErrorT
+#endif
 
 -- | create a container around the stream of ASN1
 asn1Container :: ASN1ConstructionType -> [ASN1] -> [ASN1]
diff --git a/Data/X509/PublicKey.hs b/Data/X509/PublicKey.hs
--- a/Data/X509/PublicKey.hs
+++ b/Data/X509/PublicKey.hs
@@ -80,8 +80,8 @@
                                     Right (r, xsinner) -> Right (r, xsinner ++ xs2)
             toPubKeyRSA = either Left (\(rsaKey, r) -> Right (PubKeyRSA rsaKey, r))
 
-            removeNull (Null:xs) = xs
-            removeNull l         = l
+            removeNull (Null:r) = r
+            removeNull l        = l
 
     fromASN1 l = Left ("fromASN1: X509.PubKey: unknown format:" ++ show l)
     toASN1 a = \xs -> encodePK a ++ xs
diff --git a/x509.cabal b/x509.cabal
--- a/x509.cabal
+++ b/x509.cabal
@@ -1,5 +1,5 @@
 Name:                x509
-Version:             1.4.13
+Version:             1.5.0
 Description:         X509 reader and writer
 License:             BSD3
 License-file:        LICENSE
@@ -21,11 +21,11 @@
                    , directory
                    , filepath
                    , process
-                   , time
+                   , hourglass
                    , pem >= 0.1 && < 0.3
-                   , asn1-types >= 0.2.3 && < 0.3
-                   , asn1-encoding >= 0.8 && < 0.9
-                   , asn1-parse >= 0.8 && < 0.9
+                   , asn1-types >= 0.3.0 && < 0.4
+                   , asn1-encoding >= 0.9 && < 0.10
+                   , asn1-parse >= 0.9 && < 0.10
                    , crypto-pubkey-types >= 0.4.2.1 && < 0.5
                    , cryptohash >= 0.9 && < 0.12
   Exposed-modules:   Data.X509
