@@ -67,6 +67,7 @@ import Data.Vector qualified as Vector
6767import Data.X509 qualified as X
6868import Data.X509.CertificateStore qualified as X
6969import Data.X509.Memory qualified as X
70+ import Data.X509.Validation as X
7071import GHC.ByteOrder (ByteOrder (.. ), targetByteOrder )
7172import GHC.Conc qualified as STM
7273import GHC.Exts (Int (.. ), indexWord8ArrayAsWord16 #, indexWord8ArrayAsWord32 #, indexWord8ArrayAsWord64 #, readWord8ArrayAsWord16 #, readWord8ArrayAsWord32 #, readWord8ArrayAsWord64 #, writeWord8ArrayAsWord16 #, writeWord8ArrayAsWord32 #, writeWord8ArrayAsWord64 #)
@@ -479,11 +480,28 @@ foreignCallHelper = \case
479480 updateClient certs client = client {TLS. clientShared = ((clientShared client) {TLS. sharedCAStore = certs})}
480481 in mkForeign $
481482 \ (certs :: [X. SignedCertificate ], params :: ClientParams ) -> pure $ updateClient (X. makeCertificateStore certs) params
483+ Tls_ClientConfig_certificates_get ->
484+ mkForeign $
485+ \ (client :: TLS. ClientParams ) -> pure $ X. listCertificates $ TLS. sharedCAStore $ TLS. clientShared client
486+ Tls_ClientConfig_validation_disableHostNameValidation ->
487+ let customChecks = X. defaultChecks {checkFQHN = False }
488+ customHooks = def {TLS. onServerCertificate = X. validate X. HashSHA256 defaultHooks customChecks}
489+ in mkForeign $
490+ \ (params :: TLS. ClientParams ) ->
491+ pure $ params {TLS. clientHooks = customHooks}
492+ Tls_ClientConfig_validation_disableCertificateValidation ->
493+ let customHooks = def {TLS. onServerCertificate = \ _ _ _ _ -> pure [] }
494+ in mkForeign $
495+ \ (params :: TLS. ClientParams ) ->
496+ pure $ params {TLS. clientHooks = customHooks}
482497 Tls_ServerConfig_certificates_set ->
483498 let updateServer :: X. CertificateStore -> TLS. ServerParams -> TLS. ServerParams
484499 updateServer certs client = client {TLS. serverShared = ((serverShared client) {TLS. sharedCAStore = certs})}
485500 in mkForeign $
486501 \ (certs :: [X. SignedCertificate ], params :: ServerParams ) -> pure $ updateServer (X. makeCertificateStore certs) params
502+ Tls_ServerConfig_certificates_get ->
503+ mkForeign $
504+ \ (params :: ServerParams ) -> pure $ X. listCertificates $ TLS. sharedCAStore $ serverShared params
487505 TVar_new -> mkForeign $
488506 \ (c :: Val ) -> unsafeSTMToIO $ STM. newTVar c
489507 TVar_read -> mkForeign $
0 commit comments