If
cert = crypto.dump_certificate(crypto.FILETYPE_PEM, k)
doesn't do what you want, then it doesn't look like pyOpenSSL supports public key reset. There is no branch connected here that adds this functionality, but I cannot claim that it does what the goal is.
source share