diff --git a/HsOpenSSL.cabal b/HsOpenSSL.cabal
--- a/HsOpenSSL.cabal
+++ b/HsOpenSSL.cabal
@@ -15,7 +15,7 @@
     encourages you to use and improve the tls package instead as long
     as possible.
     .
-Version:       0.10.2
+Version:       0.10.2.1
 License:       PublicDomain
 License-File:  COPYING
 Author:        Adam Langley, Mikhail Vorozhtsov, PHO, Taru Karttunen
@@ -47,7 +47,13 @@
     Location: git://github.com/phonohawk/HsOpenSSL.git
 
 Library
-  Build-Depends: base >= 4 && < 5, bytestring, ghc-prim, time >= 1.1.1, old-locale, network>=2.1.0.0
+  Build-Depends:
+      base       >= 4 && < 5,
+      bytestring,
+      ghc-prim,
+      network    >= 2.1.0.0,
+      old-locale,
+      time       >= 1.1.1
 
   if impl(ghc >= 6.11)
       Build-Depends:      integer-gmp
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,16 @@
 -*- coding: utf-8 -*-
 
+Changes from 0.10.2 to 0.10.2.1
+-------------------------------
+* Merged #10 "Fix X509 PEM reading/writing" by Mikhail Vorozhtsov:
+
+  - OpenSSL.PEM.readX509 now uses PEM_read_bio_X509() instead of
+    PEM_read_bio_X509_AUX().
+
+  - OpenSSL.PEM.writeX509 now uses PEM_write_bio_X509() instead of
+    PEM_write_bio_X509_AUX().
+
+
 Changes from 0.10.1.4 to 0.10.2
 -------------------------------
 * Merged #9 "Add raw pointer read/write operations" by Iavor
diff --git a/OpenSSL/PEM.hsc b/OpenSSL/PEM.hsc
--- a/OpenSSL/PEM.hsc
+++ b/OpenSSL/PEM.hsc
@@ -273,23 +273,23 @@
 
 {- 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 unsafe "PEM_write_bio_X509"
+        _write_bio_X509 :: 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 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 ()
 
@@ -306,7 +306,7 @@
 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
 
