< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 31
Coverable lines: 31
Total lines: 74
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 12
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
File 1: GetRemoteCertificatesFromStoreContext(...)0%220%
File 2: GetRemoteCertificatesFromStoreContext(...)0%10100%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/Common/src/Interop/Windows/SChannel/UnmanagedCertificateContext.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Diagnostics;
 5using System.Net.Security;
 6using System.Runtime.InteropServices;
 7using System.Security.Cryptography.X509Certificates;
 8
 9namespace System.Net
 10{
 11    internal static partial class UnmanagedCertificateContext
 12    {
 13        internal static void GetRemoteCertificatesFromStoreContext(SafeFreeCertContext certContext, X509Certificate2Coll
 014        {
 015            if (certContext.IsInvalid)
 016            {
 017                return;
 18            }
 19
 020            GetRemoteCertificatesFromStoreContext(certContext.DangerousGetHandle(), collection);
 021        }
 22    }
 23}
 24

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/Common/src/Interop/Windows/SChannel/UnmanagedCertificateContext.IntPtr.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Diagnostics;
 5using System.Net.Security;
 6using System.Runtime.InteropServices;
 7using System.Security.Cryptography.X509Certificates;
 8
 9namespace System.Net
 10{
 11    internal static partial class UnmanagedCertificateContext
 12    {
 13        internal static unsafe void GetRemoteCertificatesFromStoreContext(IntPtr certContext, X509Certificate2Collection
 014        {
 015            if (certContext == IntPtr.Zero)
 016            {
 017                return;
 18            }
 19
 020            Interop.Crypt32.CERT_CONTEXT context = *(Interop.Crypt32.CERT_CONTEXT*)certContext;
 21
 022            if (context.hCertStore != IntPtr.Zero)
 023            {
 024                Interop.Crypt32.CERT_CONTEXT* last = null;
 25
 026                while (true)
 027                {
 028                    Interop.Crypt32.CERT_CONTEXT* next =
 029                        Interop.Crypt32.CertEnumCertificatesInStore(context.hCertStore, last);
 30
 031                    if (next == null)
 032                    {
 033                        break;
 34                    }
 35
 036                    if ((IntPtr)next != certContext)
 037                    {
 038                        var cert = new X509Certificate2(new IntPtr(next));
 039                        if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(certContext, $"Adding remote certificate
 40
 041                        result.Add(cert);
 042                    }
 43
 044                    last = next;
 045                }
 046            }
 047        }
 48    }
 49}
 50