System.Net.HttpListenerRequest.GetClientCertificate C# (CSharp) Method

GetClientCertificate() public method

public GetClientCertificate ( ) : X509Certificate2
return System.Security.Cryptography.X509Certificates.X509Certificate2
        public X509Certificate2 GetClientCertificate()
        {
            throw new PlatformNotSupportedException();
        }

Usage Example

Esempio n. 1
0
        private Request ConvertRequest(Uri baseUri, HttpListenerRequest httpRequest)
        {
            var expectedRequestLength = GetExpectedRequestLength(ConvertToDictionary(httpRequest.Headers));

            var url = new Url
            {
                Scheme = httpRequest.Url.Scheme,
                HostName = httpRequest.Url.Host,
                Port = httpRequest.Url.IsDefaultPort ? null : (int?)httpRequest.Url.Port,
                BasePath = baseUri.AbsolutePath.TrimEnd('/'),
                Path = baseUri.MakeAppLocalPath(httpRequest.Url),
                Query = httpRequest.Url.Query,
            };

            var fieldCount = httpRequest.ProtocolVersion.Major == 2 ? 1 : 2;
            var protocolVersion = string.Format("HTTP/{0}", httpRequest.ProtocolVersion.ToString(fieldCount));

            byte[] certificate = null;
            if (httpRequest.IsSecureConnection)
            {
                var x509Certificate = httpRequest.GetClientCertificate();
                if (x509Certificate != null)
                {
                    certificate = x509Certificate.RawData;
                }
            }

            return new Request(
                httpRequest.HttpMethod,
                url,
                RequestStream.FromStream(httpRequest.InputStream, expectedRequestLength, false),
                ConvertToDictionary(httpRequest.Headers),
                (httpRequest.RemoteEndPoint != null) ? httpRequest.RemoteEndPoint.Address.ToString() : null,
                protocolVersion,
                certificate);
        }
All Usage Examples Of System.Net.HttpListenerRequest::GetClientCertificate