Merge pull request #435 from reaperhulk/m-asn1-time-dup

X509_REVOKED_dup is a thing cryptography can do for you
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py
index acc9c5c..b2b858e 100644
--- a/src/OpenSSL/crypto.py
+++ b/src/OpenSSL/crypto.py
@@ -217,15 +217,22 @@
                 _raise_current_error()
 
         elif type == TYPE_DSA:
-            dsa = _lib.DSA_generate_parameters(
-                bits, _ffi.NULL, 0, _ffi.NULL, _ffi.NULL, _ffi.NULL, _ffi.NULL)
+            dsa = _lib.DSA_new()
             if dsa == _ffi.NULL:
                 # TODO: This is untested.
                 _raise_current_error()
+
+            dsa = _ffi.gc(dsa, _lib.DSA_free)
+            res = _lib.DSA_generate_parameters_ex(
+                dsa, bits, _ffi.NULL, 0, _ffi.NULL, _ffi.NULL, _ffi.NULL
+            )
+            if not res == 1:
+                # TODO: This is untested.
+                _raise_current_error()
             if not _lib.DSA_generate_key(dsa):
                 # TODO: This is untested.
                 _raise_current_error()
-            if not _lib.EVP_PKEY_assign_DSA(self._pkey, dsa):
+            if not _lib.EVP_PKEY_set1_DSA(self._pkey, dsa):
                 # TODO: This is untested.
                 _raise_current_error()
         else: