internal HttpListenerRequest(HttpListenerContext httpContext, RequestContextBase memoryBlob)
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Info(this, $"httpContext:${httpContext} memoryBlob {((IntPtr)memoryBlob.RequestBlob)}");
                NetEventSource.Associate(this, httpContext);
            }
            _httpContext = httpContext;
            _memoryBlob = memoryBlob;
            _boundaryType = BoundaryType.None;

            // Set up some of these now to avoid refcounting on memory blob later.
            _requestId = memoryBlob.RequestBlob->RequestId;
            _connectionId = memoryBlob.RequestBlob->ConnectionId;
            _sslStatus = memoryBlob.RequestBlob->pSslInfo == null ? SslStatus.Insecure :
                memoryBlob.RequestBlob->pSslInfo->SslClientCertNegotiated == 0 ? SslStatus.NoClientCert :
                SslStatus.ClientCert;
            if (memoryBlob.RequestBlob->pRawUrl != null && memoryBlob.RequestBlob->RawUrlLength > 0)
            {
                _rawUrl = Marshal.PtrToStringAnsi((IntPtr)memoryBlob.RequestBlob->pRawUrl, memoryBlob.RequestBlob->RawUrlLength);
            }

            Interop.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob->CookedUrl;
            if (cookedUrl.pHost != null && cookedUrl.HostLength > 0)
            {
                _cookedUrlHost = Marshal.PtrToStringUni((IntPtr)cookedUrl.pHost, cookedUrl.HostLength / 2);
            }
            if (cookedUrl.pAbsPath != null && cookedUrl.AbsPathLength > 0)
            {
                _cookedUrlPath = Marshal.PtrToStringUni((IntPtr)cookedUrl.pAbsPath, cookedUrl.AbsPathLength / 2);
            }
            if (cookedUrl.pQueryString != null && cookedUrl.QueryStringLength > 0)
            {
                _cookedUrlQuery = Marshal.PtrToStringUni((IntPtr)cookedUrl.pQueryString, cookedUrl.QueryStringLength / 2);
            }
            _version = new Version(memoryBlob.RequestBlob->Version.MajorVersion, memoryBlob.RequestBlob->Version.MinorVersion);
            _clientCertState = ListenerClientCertState.NotInitialized;
            _keepAlive = null;
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Info(this, $"RequestId:{RequestId} ConnectionId:{_connectionId} RawConnectionId:{memoryBlob.RequestBlob->RawConnectionId} UrlContext:{memoryBlob.RequestBlob->UrlContext} RawUrl:{_rawUrl} Version:{_version} Secure:{_sslStatus}");
                NetEventSource.Info(this, $"httpContext:${httpContext} RequestUri:{RequestUri} Content-Length:{ContentLength64} HTTP Method:{HttpMethod}");
            }
            // Log headers
            if (NetEventSource.IsEnabled)
            {
                StringBuilder sb = new StringBuilder("HttpListenerRequest Headers:\n");
                for (int i = 0; i < Headers.Count; i++)
                {
                    sb.Append("\t");
                    sb.Append(Headers.GetKey(i));
                    sb.Append(" : ");
                    sb.Append(Headers.Get(i));
                    sb.Append("\n");
                }
                NetEventSource.Info(this, sb.ToString());
            }
        }
 internal unsafe HttpListenerRequest(System.Net.HttpListenerContext httpContext, RequestContextBase memoryBlob)
 {
     if (Logging.On)
     {
         Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " memoryBlob# " + ValidationHelper.HashString((IntPtr) memoryBlob.RequestBlob));
     }
     if (Logging.On)
     {
         Logging.Associate(Logging.HttpListener, this, httpContext);
     }
     this.m_HttpContext = httpContext;
     this.m_MemoryBlob = memoryBlob;
     this.m_BoundaryType = BoundaryType.None;
     this.m_RequestId = memoryBlob.RequestBlob.RequestId;
     this.m_ConnectionId = memoryBlob.RequestBlob.ConnectionId;
     this.m_SslStatus = (memoryBlob.RequestBlob.pSslInfo == null) ? SslStatus.Insecure : ((memoryBlob.RequestBlob.pSslInfo.SslClientCertNegotiated == 0) ? SslStatus.NoClientCert : SslStatus.ClientCert);
     if ((memoryBlob.RequestBlob.pRawUrl != null) && (memoryBlob.RequestBlob.RawUrlLength > 0))
     {
         this.m_RawUrl = Marshal.PtrToStringAnsi((IntPtr) memoryBlob.RequestBlob.pRawUrl, memoryBlob.RequestBlob.RawUrlLength);
     }
     UnsafeNclNativeMethods.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob.CookedUrl;
     if ((cookedUrl.pHost != null) && (cookedUrl.HostLength > 0))
     {
         this.m_CookedUrlHost = Marshal.PtrToStringUni((IntPtr) cookedUrl.pHost, cookedUrl.HostLength / 2);
     }
     if ((cookedUrl.pAbsPath != null) && (cookedUrl.AbsPathLength > 0))
     {
         this.m_CookedUrlPath = Marshal.PtrToStringUni((IntPtr) cookedUrl.pAbsPath, cookedUrl.AbsPathLength / 2);
     }
     if ((cookedUrl.pQueryString != null) && (cookedUrl.QueryStringLength > 0))
     {
         this.m_CookedUrlQuery = Marshal.PtrToStringUni((IntPtr) cookedUrl.pQueryString, cookedUrl.QueryStringLength / 2);
     }
     this.m_Version = new Version(memoryBlob.RequestBlob.Version.MajorVersion, memoryBlob.RequestBlob.Version.MinorVersion);
     this.m_ClientCertState = ListenerClientCertState.NotInitialized;
     this.m_KeepAlive = TriState.Unspecified;
     if (Logging.On)
     {
         Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " RequestUri:" + ValidationHelper.ToString(this.RequestUri) + " Content-Length:" + ValidationHelper.ToString(this.ContentLength64) + " HTTP Method:" + ValidationHelper.ToString(this.HttpMethod));
     }
     if (Logging.On)
     {
         StringBuilder builder = new StringBuilder("HttpListenerRequest Headers:\n");
         for (int i = 0; i < this.Headers.Count; i++)
         {
             builder.Append("\t");
             builder.Append(this.Headers.GetKey(i));
             builder.Append(" : ");
             builder.Append(this.Headers.Get(i));
             builder.Append("\n");
         }
         Logging.PrintInfo(Logging.HttpListener, this, ".ctor", builder.ToString());
     }
 }
Exemple #3
0
 public SslRecordStatus(SslStatus status, byte[] buffer, byte[] decrypted)
 {
     this.Status = status;
     this.Buffer = buffer;
     this.Decrypted = decrypted;
 }
        internal HttpListenerRequest(HttpListenerContext httpContext, RequestContextBase memoryBlob)
        {
            if (Logging.On) Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#" + ValidationHelper.HashString(httpContext) + " memoryBlob# " + ValidationHelper.HashString((IntPtr) memoryBlob.RequestBlob));
            if(Logging.On)Logging.Associate(Logging.HttpListener, this, httpContext);
            m_HttpContext = httpContext;
            m_MemoryBlob = memoryBlob;
            m_BoundaryType = BoundaryType.None;

            // Set up some of these now to avoid refcounting on memory blob later.
            m_RequestId = memoryBlob.RequestBlob->RequestId;
            m_ConnectionId = memoryBlob.RequestBlob->ConnectionId;
            m_SslStatus = memoryBlob.RequestBlob->pSslInfo == null ? SslStatus.Insecure :
                memoryBlob.RequestBlob->pSslInfo->SslClientCertNegotiated == 0 ? SslStatus.NoClientCert :
                SslStatus.ClientCert;
            if (memoryBlob.RequestBlob->pRawUrl != null && memoryBlob.RequestBlob->RawUrlLength > 0) {
                m_RawUrl = Marshal.PtrToStringAnsi((IntPtr) memoryBlob.RequestBlob->pRawUrl, memoryBlob.RequestBlob->RawUrlLength);
            }
            
            UnsafeNclNativeMethods.HttpApi.HTTP_COOKED_URL cookedUrl = memoryBlob.RequestBlob->CookedUrl;
            if (cookedUrl.pHost != null && cookedUrl.HostLength > 0) {
                m_CookedUrlHost = Marshal.PtrToStringUni((IntPtr)cookedUrl.pHost, cookedUrl.HostLength / 2);
            }
            if (cookedUrl.pAbsPath != null && cookedUrl.AbsPathLength > 0) {
                m_CookedUrlPath = Marshal.PtrToStringUni((IntPtr)cookedUrl.pAbsPath, cookedUrl.AbsPathLength / 2);
            }
            if (cookedUrl.pQueryString != null && cookedUrl.QueryStringLength > 0) {
                m_CookedUrlQuery = Marshal.PtrToStringUni((IntPtr)cookedUrl.pQueryString, cookedUrl.QueryStringLength / 2);
            }
            m_Version = new Version(memoryBlob.RequestBlob->Version.MajorVersion, memoryBlob.RequestBlob->Version.MinorVersion);
            m_ClientCertState = ListenerClientCertState.NotInitialized;
            m_KeepAlive = TriState.Unspecified;
            GlobalLog.Print("HttpListenerContext#" + ValidationHelper.HashString(this) + "::.ctor() RequestId:" + RequestId + " ConnectionId:" + m_ConnectionId + " RawConnectionId:" + memoryBlob.RequestBlob->RawConnectionId + " UrlContext:" + memoryBlob.RequestBlob->UrlContext + " RawUrl:" + m_RawUrl + " Version:" + m_Version.ToString() + " Secure:" + m_SslStatus.ToString());
            if(Logging.On)Logging.PrintInfo(Logging.HttpListener, this, ".ctor", "httpContext#"+ ValidationHelper.HashString(httpContext)+ " RequestUri:" + ValidationHelper.ToString(RequestUri) + " Content-Length:" + ValidationHelper.ToString(ContentLength64) + " HTTP Method:" + ValidationHelper.ToString(HttpMethod));
            // Log headers
            if(Logging.On) {
                StringBuilder sb = new StringBuilder("HttpListenerRequest Headers:\n");
                for (int i=0; i<Headers.Count; i++) {
                    sb.Append("\t");
                    sb.Append(Headers.GetKey(i));
                    sb.Append(" : ");
                    sb.Append(Headers.Get(i));
                    sb.Append("\n");
                }
                Logging.PrintInfo(Logging.HttpListener, this, ".ctor", sb.ToString());
            }
        }
Exemple #5
0
        void CheckStatusAndThrow(SslStatus status, params SslStatus[] acceptable)
        {
            var last = Interlocked.Exchange (ref lastException, null);
            if (last != null)
                throw last;

            if (status == SslStatus.Success || acceptable.Contains (status))
                return;

            switch (status) {
            case SslStatus.ClosedAbort:
                throw new IOException ("Connection closed.");

            case SslStatus.BadCert:
                throw new TlsException (AlertDescription.BadCertificate);

            case SslStatus.UnknownRootCert:
            case SslStatus.NoRootCert:
            case SslStatus.XCertChainInvalid:
                throw new TlsException (AlertDescription.CertificateUnknown, status.ToString ());

            case SslStatus.CertExpired:
            case SslStatus.CertNotYetValid:
                throw new TlsException (AlertDescription.CertificateExpired);

            case SslStatus.Protocol:
                throw new TlsException (AlertDescription.ProtocolVersion);

            default:
                throw new TlsException (AlertDescription.InternalError, "Unknown Secure Transport error `{0}'.", status);
            }
        }
Exemple #6
0
 public SslHandshakeStatus(SslStatus status, byte[] message)
 {
     this.Status = status;
     this.Message = message;
 }
Exemple #7
0
 public SslStatus SetClientSideAuthenticate(SslAuthenticate auth)
 {
     result = SSLSetClientSideAuthenticate(Handle, auth);
     return(result);
 }
Exemple #8
0
 public SslStatus SetSessionOption(SslSessionOption option, bool value)
 {
     result = SSLSetSessionOption(Handle, option, value);
     return(result);
 }
Exemple #9
0
 public SslStatus GetSessionOption(SslSessionOption option, out bool value)
 {
     result = SSLGetSessionOption(Handle, option, out value);
     return(result);
 }
Exemple #10
0
 public SslStatus Handshake()
 {
     result = SSLHandshake(Handle);
     return(result);
 }
 /// <summary>
 /// Initializes a new instance of the StorageAccountCredential class.
 /// </summary>
 /// <param name="cloudType">The cloud service provider. Possible values
 /// include: 'Azure', 'S3', 'S3_RRS', 'OpenStack', 'HP'</param>
 /// <param name="endPoint">The storage endpoint</param>
 /// <param name="login">The storage account login</param>
 /// <param name="enableSSL">SSL needs to be enabled or not. Possible
 /// values include: 'Enabled', 'Disabled'</param>
 /// <param name="id">The identifier.</param>
 /// <param name="name">The name.</param>
 /// <param name="type">The type.</param>
 /// <param name="location">The storage account's geo location</param>
 /// <param name="accessKey">The details of the storage account
 /// password</param>
 public StorageAccountCredential(CloudType cloudType, string endPoint, string login, SslStatus enableSSL, string id = default(string), string name = default(string), string type = default(string), string location = default(string), AsymmetricEncryptedSecret accessKey = default(AsymmetricEncryptedSecret))
     : base(id, name, type)
 {
     CloudType = cloudType;
     EndPoint  = endPoint;
     Login     = login;
     Location  = location;
     EnableSSL = enableSSL;
     AccessKey = accessKey;
     CustomInit();
 }