Add abstractions for accessing client certificate state.

This commit is contained in:
Martin Grabmueller 2012-07-13 21:44:19 +02:00
parent e617a1bbec
commit 6483e954f4

View file

@ -419,3 +419,25 @@ handshake ctx = do
sendPacket ctx (errorToAlert tlserror) sendPacket ctx (errorToAlert tlserror)
handshakeFailed tlserror handshakeFailed tlserror
withClientCertServer :: MonadIO m => Context -> (ClientCertParamsServer -> m a) -> m a
withClientCertServer ctx f =
case pClientCertParamsServer $ ctxParams ctx of
Nothing ->
throwCore $ Error_Misc "client certificates not configured"
Just cpp ->
f cpp
withClientCertClient :: MonadIO m => Context -> (ClientCertParamsClient -> m a) -> m a
withClientCertClient ctx f =
case pClientCertParamsClient $ ctxParams ctx of
Nothing ->
throwCore $ Error_Misc "client certificates not configured"
Just cpp ->
f cpp
throwMiscErrorOnException :: MonadIO m => String -> SomeException -> m a
throwMiscErrorOnException msg e =
throwCore $ Error_Misc $ msg ++ ": " ++ show e