Add CryptoNative_X509UpRef
Use X509UpRef instead of X509Duplicate
X509Duplicate copies the certificate data into new memory, but none of the
callers needed copy semantics, just ensuring that the native components
which also are using the same memory don't unexpectedly free the object.
Protection from early/double-free is what the native reference count field is
for, so use UpRef instead of Duplicate.
Since we are currently targeting OpenSSL 1.0.x X509Upref adds to
references directly, X509_up_ref does not exist in the 1.0.x ABI.
Microbenchmark:
Cloning a certificate 1000 times by cert.Handle, measuring maximum resident set:
X509Duplicate (before): 48213 +/- 1501KB
X509UpRef (after): 39208 +/- 1021KB
Memory reduction: 9005 +/- 1816KB
Commit migrated from https://github.com/dotnet/corefx/commit/
8f5eac55eb498c3c94f5a89655f4d7ad79a8711a