Use CertFreeCertificateContext from Common Interop in X509Certificates
authorAdam Gauthier <adamgauthier12@gmail.com>
Wed, 25 Jul 2018 23:45:31 +0000 (19:45 -0400)
committerJeremy Barton <jbarton@microsoft.com>
Wed, 25 Jul 2018 23:45:31 +0000 (16:45 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/0c044218122730ff2f91e771ee3e372b89e6e759

src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CertFreeCertificateContext.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/Interop.crypt32.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/Native/SafeHandles.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj

index d48b7a5..ad6371b 100644 (file)
@@ -9,7 +9,7 @@ internal static partial class Interop
 {
     internal static partial class Crypt32
     {
-        [DllImport(Interop.Libraries.Crypt32, SetLastError = true)]
+        [DllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
         internal static extern bool CertFreeCertificateContext(IntPtr pCertContext);
     }
 }
index 8c99f63..1ab1329 100644 (file)
@@ -312,9 +312,6 @@ internal static partial class Interop
         private static extern bool CertVerifyCertificateChainPolicy(IntPtr pszPolicyOID, SafeX509ChainHandle pChainContext, [In] ref CERT_CHAIN_POLICY_PARA pPolicyPara, [In, Out] ref CERT_CHAIN_POLICY_STATUS pPolicyStatus);
 
         [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
-        public static extern bool CertFreeCertificateContext(IntPtr pCertContext);
-
-        [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
         public static extern bool CertCloseStore(IntPtr hCertStore, int dwFlags);
 
         [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
index c12344f..25b9f9e 100644 (file)
@@ -72,7 +72,7 @@ namespace Internal.Cryptography.Pal.Native
             }
             else
             {
-                Interop.crypt32.CertFreeCertificateContext(handle);
+                Interop.Crypt32.CertFreeCertificateContext(handle);
             }
 
             SetHandle(IntPtr.Zero);
index 3b5bfd2..f8ec18e 100644 (file)
     <Compile Include="Internal\Cryptography\Pal.Windows\X509Pal.PublicKey.cs" />
     <Compile Include="Internal\Cryptography\Pal.Windows\X509Pal.X500DistinguishedName.cs" />
     <Compile Include="Microsoft\Win32\SafeHandles\SafePasswordHandle.Windows.cs" />
+    <Compile Include="$(CommonPath)\Interop\Windows\Crypt32\Interop.CertFreeCertificateContext.cs">
+      <Link>Common\Interop\Windows\Crypt32\Interop.CertFreeCertificateContext.cs</Link>
+    </Compile>
     <Compile Include="$(CommonPath)\Interop\Windows\Crypt32\Interop.FindOidInfo.cs">
       <Link>Common\Interop\Windows\Crypt32\Interop.FindOidInfo.cs</Link>
     </Compile>