Beispiel #1
0
        private const int ServerReadTimeoutInSeconds = 3;   // TODO: Have this configurable in case this isn't big enough.

        public static async Task <IEnumerable <ProtocolVersion> > GetSupportedProtocolVersionsAsync(string hostName, int port = 443)
        {
            List <ProtocolVersion> supportedVersions = new List <ProtocolVersion>();

            foreach (var version in Enum.GetValues(typeof(ProtocolVersion)).Cast <ProtocolVersion>())
            {
                Record response = await SendClientHelloAsync(TlsRequestParameters.Create(hostName, port, version, version, null));

                bool supported = response.ContentType == RecordContentTypes.Handshake;
                if (supported)
                {
                    supportedVersions.Add(version);
                }
            }

            return(supportedVersions);
        }
Beispiel #2
0
        public static async Task <IEnumerable <CipherSuites> > GetSupportedCipherSuitesAsync(string hostName, int port = 443, ProtocolVersion protocolVersion = ProtocolVersion.Tls12)
        {
            List <CipherSuites> supportedCipherSuites = new List <CipherSuites>();

            foreach (CipherSuites suite in Enum.GetValues(typeof(CipherSuites)).Cast <CipherSuites>())
            {
                Record response = await SendClientHelloAsync(TlsRequestParameters.Create(hostName, port, protocolVersion, protocolVersion, new CipherSuites[] { suite }));

                if (response == null)
                {
                    throw new Exception("No response received from server. Check the host name and port number.");
                }

                bool supported = response.ContentType == RecordContentTypes.Handshake;
                if (supported)
                {
                    supportedCipherSuites.Add(suite);
                }
            }

            return(supportedCipherSuites);
        }