示例#1
0
        public static void Test1()
        {
            IDnsSecResolver            resolver = new SelfValidatingInternalDnsSecStubResolver();
            DnsSecResult <SshFpRecord> result   = resolver.ResolveSecure <SshFpRecord>("example.com", RecordType.SshFp);

            if (result.ValidationResult == DnsSecValidationResult.Signed)
            {
                System.Console.WriteLine("example.com has following signed SSH fingerprint records:");
                result.Records.ForEach(x => System.Console.WriteLine(x.ToString()));
            }
            else
            {
                System.Console.WriteLine("example.com has no signed SSH fingerprint records");
            }
        } // End Sub Test1
		/// <summary>
		///   Called by clients to authenticate the server and optionally the client in a client-server connection.
		/// </summary>
		/// <param name="targetHost">The name of the server</param>
		/// <param name="port">The port of the server</param>
		/// <param name="protocol">The protocol used to communicate with the server</param>
		/// <param name="clientCertificates">The X509CertificateCollection that contains client certificates.</param>
		/// <param name="enabledSslProtocols">The SslProtocols value that represents the protocol used for authentication.</param>
		/// <param name="checkCertificateRevocation">
		///   A Boolean value that specifies whether the certificate revocation list is
		///   checked during authentication.
		/// </param>
		public async Task AuthenticateAsClientAsync(string targetHost, int port, ProtocolType protocol = ProtocolType.Tcp, X509CertificateCollection clientCertificates = null, SslProtocols enabledSslProtocols = SslProtocols.Default, bool checkCertificateRevocation = false)
		{
			_tlsaRecords = await _resolver.ResolveSecureAsync<TlsaRecord>(DomainName.Parse("_" + port + "._" + EnumHelper<ProtocolType>.ToString(protocol).ToLower() + "." + targetHost), RecordType.Tlsa);
			await _sslStream.AuthenticateAsClientAsync(targetHost, clientCertificates ?? new X509CertificateCollection(), enabledSslProtocols, checkCertificateRevocation);
		}
        /// <summary>
        ///   Called by clients to authenticate the server and optionally the client in a client-server connection.
        /// </summary>
        /// <param name="targetHost">The name of the server</param>
        /// <param name="port">The port of the server</param>
        /// <param name="protocol">The protocol used to communicate with the server</param>
        /// <param name="clientCertificates">The X509CertificateCollection that contains client certificates.</param>
        /// <param name="enabledSslProtocols">The SslProtocols value that represents the protocol used for authentication.</param>
        /// <param name="checkCertificateRevocation">
        ///   A Boolean value that specifies whether the certificate revocation list is
        ///   checked during authentication.
        /// </param>
        public async Task AuthenticateAsClientAsync(string targetHost, int port, ProtocolType protocol = ProtocolType.Tcp, X509CertificateCollection clientCertificates = null, SslProtocols enabledSslProtocols = SslProtocols.Default, bool checkCertificateRevocation = false)
        {
            _tlsaRecords = await _resolver.ResolveSecureAsync <TlsaRecord>(DomainName.Parse("_" + port + "._" + EnumHelper <ProtocolType> .ToString(protocol).ToLower() + "." + targetHost), RecordType.Tlsa);

            await _sslStream.AuthenticateAsClientAsync(targetHost, clientCertificates ?? new X509CertificateCollection(), enabledSslProtocols, checkCertificateRevocation);
        }