Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Commit

Permalink
Fix X509 PEM reading/writing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mvv committed Apr 9, 2012
1 parent 24f927e commit 6c0a930
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions OpenSSL/PEM.hsc
Expand Up @@ -273,23 +273,23 @@ readPublicKey pemStr

{- X.509 certificate --------------------------------------------------------- -}

foreign import ccall unsafe "PEM_write_bio_X509_AUX"
_write_bio_X509_AUX :: Ptr BIO_
-> Ptr X509_
-> IO CInt

foreign import ccall safe "PEM_read_bio_X509_AUX"
_read_bio_X509_AUX :: Ptr BIO_
-> Ptr (Ptr X509_)
-> FunPtr PemPasswordCallback'
-> Ptr ()
-> IO (Ptr X509_)
foreign import ccall unsafe "PEM_write_bio_X509"
_write_bio_X509 :: Ptr BIO_
-> Ptr X509_
-> IO CInt

foreign import ccall safe "PEM_read_bio_X509"
_read_bio_X509 :: Ptr BIO_
-> Ptr (Ptr X509_)
-> FunPtr PemPasswordCallback'
-> Ptr ()
-> IO (Ptr X509_)

writeX509' :: BIO -> X509 -> IO ()
writeX509' bio x509
= withBioPtr bio $ \ bioPtr ->
withX509Ptr x509 $ \ x509Ptr ->
_write_bio_X509_AUX bioPtr x509Ptr
_write_bio_X509 bioPtr x509Ptr
>>= failIf (/= 1)
>> return ()

Expand All @@ -306,7 +306,7 @@ readX509' :: BIO -> IO X509
readX509' bio
= withBioPtr bio $ \ bioPtr ->
withCString "" $ \ passPtr ->
_read_bio_X509_AUX bioPtr nullPtr nullFunPtr (castPtr passPtr)
_read_bio_X509 bioPtr nullPtr nullFunPtr (castPtr passPtr)
>>= failIfNull
>>= wrapX509

Expand Down

0 comments on commit 6c0a930

Please sign in to comment.