// dotnet/wcf#1574 - This is a workaround for dotnet/corefx#12214
// The copy constructor was removed in .NET Core, this is the workaround to allow us to make copies of certificates
internal static X509Certificate2 CloneCertificateInternal(this X509Certificate2 certificateToClone)
{
#if TARGETS_WINDOWS
return new X509Certificate2(certificateToClone.Handle);
#else
X509Certificate2Collection collection = new X509Certificate2Collection(certificateToClone);
X509Certificate2Collection copyCollection = collection.Find(X509FindType.FindByThumbprint, certificateToClone.Thumbprint, false);
return copyCollection[0];
#endif
}