当前位置: 首页>>代码示例>>C#>>正文


C# RemoteCertificateValidationCallback类代码示例

本文整理汇总了C#中RemoteCertificateValidationCallback的典型用法代码示例。如果您正苦于以下问题:C# RemoteCertificateValidationCallback类的具体用法?C# RemoteCertificateValidationCallback怎么用?C# RemoteCertificateValidationCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RemoteCertificateValidationCallback类属于命名空间,在下文中一共展示了RemoteCertificateValidationCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EpoxyTlsConfig

 /// <summary>
 /// Creates a new instance of the <see cref="EpoxyTlsConfig"/> class.
 /// </summary>
 /// <param name="remoteCertificateValidationCallback">
 /// Normal use is to omit this parameter/pass <c>null</c> so that the
 /// system's default behavior is used. Passing something other than
 /// null here is almost always a bug. This delegate is passed to
 /// <see cref="SslStream"/>; consult the SslStream documentation for
 /// more details about its use.
 /// </param>
 /// <param name="checkCertificateRevocation">
 /// Whether certificate revocation is checked. Defaults to <c>true</c>.
 /// </param>
 protected EpoxyTlsConfig(
     RemoteCertificateValidationCallback remoteCertificateValidationCallback = null,
     bool checkCertificateRevocation = true)
 {
     RemoteCertificateValidationCallback = remoteCertificateValidationCallback;
     CheckCertificateRevocation = checkCertificateRevocation;
 }
开发者ID:csdahlberg,项目名称:bond,代码行数:20,代码来源:EpoxyTlsConfig.cs

示例2: ManageClientRequest

        internal static SslStream ManageClientRequest(TcpClient client)
        {
            SslStream sslStream = null;

            try
            {
                bool leaveInnerStreamOpen = true;

                RemoteCertificateValidationCallback validationCallback =
                    new RemoteCertificateValidationCallback(ClientValidationCallback);
                LocalCertificateSelectionCallback selectionCallback =
                    new LocalCertificateSelectionCallback(ServerCertificateSelectionCallback);
                EncryptionPolicy encryptionPolicy = EncryptionPolicy.AllowNoEncryption;

                sslStream = new SslStream(client.GetStream(), leaveInnerStreamOpen, validationCallback, selectionCallback, encryptionPolicy);
                Console.WriteLine("Server starting handshake");
                ServerSideHandshake(sslStream);
                Console.WriteLine("Server finished handshake");
            }
            catch(Exception ex)
            {
                sslStream = null;
                Console.WriteLine("\nError detected in sslStream: " + ex.Message);
            }
            return sslStream;
        }
开发者ID:Siryu,项目名称:Distributed-Processing-Capstone,代码行数:26,代码来源:ServerSecureSocket.cs

示例3: MailClient

 public MailClient(string hostname, int port, bool isSecure = false, RemoteCertificateValidationCallback validate = null)
 {
     this.hostName = hostname;
     this.port = port;
     this.isSecure = isSecure;
     this.validate = validate;
 }
开发者ID:hmanjarawala,项目名称:GitRepo,代码行数:7,代码来源:MailClient.cs

示例4: ManageServerRequest

        internal static SslStream ManageServerRequest(TcpClient client, String connectToIP)
        {
            SslStream sslStream = null;
            try
            {
                bool leaveInnerStreamOpen = true;

                RemoteCertificateValidationCallback validationCallback =
                    new RemoteCertificateValidationCallback(ServerValidationCallback);

                LocalCertificateSelectionCallback selectionCallback =
                    new LocalCertificateSelectionCallback(ClientCertificateSelectionCallback);

                EncryptionPolicy encryptionPolicy = EncryptionPolicy.NoEncryption;

                sslStream = new SslStream(client.GetStream(), leaveInnerStreamOpen, validationCallback, selectionCallback, encryptionPolicy);
                Console.WriteLine("Client starting handshake");
                ClientSideHandshake(sslStream, connectToIP);
                Console.WriteLine("client finished handshake");
            }
            catch(AuthenticationException ex)
            {
                Console.WriteLine("\nAuthentication Exception: " + ex.Message);
            }
            catch(Exception ex)
            {
                Console.WriteLine("\nError detected: " + ex.Message);
            }

            return sslStream;
        }
开发者ID:Siryu,项目名称:Distributed-Processing-Capstone,代码行数:31,代码来源:ClientSecureSocket.cs

示例5: TTlsServerSocketTransport

        public TTlsServerSocketTransport(
            int port,
            bool useBufferedSockets,
            X509Certificate2 certificate,
            RemoteCertificateValidationCallback clientCertValidator = null,
            LocalCertificateSelectionCallback localCertificateSelectionCallback = null,
            SslProtocols sslProtocols = SslProtocols.Tls12)
        {
            if (!certificate.HasPrivateKey)
            {
                throw new TTransportException(TTransportException.ExceptionType.Unknown,
                    "Your server-certificate needs to have a private key");
            }

            _port = port;
            _serverCertificate = certificate;
            _useBufferedSockets = useBufferedSockets;
            _clientCertValidator = clientCertValidator;
            _localCertificateSelectionCallback = localCertificateSelectionCallback;
            _sslProtocols = sslProtocols;

            try
            {
                // Create server socket
                _server = new TcpListener(IPAddress.Any, _port);
                _server.Server.NoDelay = true;
            }
            catch (Exception)
            {
                _server = null;
                throw new TTransportException($"Could not create ServerSocket on port {port}.");
            }
        }
开发者ID:nsuke,项目名称:thrift,代码行数:33,代码来源:TTlsServerSocketTransport.cs

示例6: MailClient

 protected MailClient(string host, int port, bool isSsl, RemoteCertificateValidationCallback validate)
 {
     HostName = host;
     PortNo = port;
     IsSsl = isSsl;
     Validate = validate;
 }
开发者ID:hmanjarawala,项目名称:GitRepo,代码行数:7,代码来源:MailClient.cs

示例7: SslStream

 public SslStream(
   NetworkStream innerStream,
   bool leaveInnerStreamOpen,
   RemoteCertificateValidationCallback userCertificateValidationCallback
 ) : base(innerStream, leaveInnerStreamOpen, userCertificateValidationCallback)
 {
 }
开发者ID:fengxianqi,项目名称:Youbang,代码行数:7,代码来源:SslStream.cs

示例8: PublicToMono

		internal static MSI.MonoRemoteCertificateValidationCallback PublicToMono (RemoteCertificateValidationCallback callback)
		{
			if (callback == null)
				return null;

			return (h, c, ch, e) => callback (h, c, (X509Chain)(object)ch, (SslPolicyErrors)e);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:CallbackHelpers.cs

示例9: SecureTcpServer

        public SecureTcpServer(int listenPort, X509Certificate serverCertificate,
            SecureConnectionResultsCallback callback,
            RemoteCertificateValidationCallback certValidationCallback)
        {
            if (listenPort < 0 || listenPort > UInt16.MaxValue)
                throw new ArgumentOutOfRangeException("listenPort");

            if (serverCertificate == null)
                throw new ArgumentNullException("serverCertificate");

            if (callback == null)
                throw new ArgumentNullException("callback");

            onAcceptConnection = new AsyncCallback(OnAcceptConnection);
            onAuthenticateAsServer = new AsyncCallback(OnAuthenticateAsServer);

            this.serverCert = serverCertificate;
            this.certValidationCallback = certValidationCallback;
            this.connectionCallback = callback;
            this.listenPort = listenPort;
            this.disposed = 0;
            this.checkCertifcateRevocation = false;
            this.clientCertificateRequired = false;
            this.sslProtocols = SslProtocols.Default;
        }
开发者ID:BGCX262,项目名称:zynchronyze-svn-to-git,代码行数:25,代码来源:SecureTcpServer.cs

示例10: TcpClientAdapter

        internal TcpClientAdapter()
        {
            _sendQueue = new Queue<SendState>();

            _sendCallback = new AsyncCallback(sendHandler);
            _receiveCallback = new AsyncCallback(receiveHandler);
            _certCallback = new RemoteCertificateValidationCallback(ValidateCert);
        }
开发者ID:hydna,项目名称:Hydna.NET,代码行数:8,代码来源:TcpClientAdapter.cs

示例11: SslClient

        /// <summary>
        /// Initialises ssl client as a client side endpoint.
        /// </summary>
        public SslClient(IRawByteClient client,
                         string targetHost,
                         RemoteCertificateValidationCallback remoteCertificateValidationCallback)
        {
            Ensure.IsNotNull(client, "client");
            Ensure.IsNotNullOrWhiteSpace(targetHost, "targetHost");

            InitializeAsClient(client, targetHost, remoteCertificateValidationCallback);
        }
开发者ID:wushian,项目名称:Stacks,代码行数:12,代码来源:SslClient.cs

示例12: BaseHttpQrCodeProvider

        /// <summary>
        /// Initializes a new instance of a <see cref="BaseHttpQrCodeProvider"/>.
        /// </summary>
        /// <param name="baseUri">The base Uri for the QR code provider.</param>
        /// <param name="remoteCertificateValidationCallback">
        /// The <see cref="RemoteCertificateValidationCallback"/> to be used by the QR code provider.
        /// </param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="baseUri"/> is null.</exception>
        protected BaseHttpQrCodeProvider(Uri baseUri, RemoteCertificateValidationCallback remoteCertificateValidationCallback)
        {
            if (baseUri == null)
                throw new ArgumentNullException("baseUri");
            this.BaseUri = baseUri;

            this.RemoteCertificateValidationCallback = remoteCertificateValidationCallback;
            this.TimeOut = DEFAULTTIMEOUT;
        }
开发者ID:RobThree,项目名称:TwoFactorAuth.Net,代码行数:17,代码来源:BaseHttpQrCodeProvider.cs

示例13: UploadFiles

        //private string hostname, username, password;
        public static void UploadFiles(ConfigurationProfile profile, string temppath, string remotedir)
        {
            // Setup session options
            // add support for: scp/sftp protocols, ssh host/private keys, active/passive mode, port, FtpSecure, timeout, ssl cert,

            using (FTPSClient session = new FTPSClient())
            {

                ESSLSupportMode sslSupportMode = ESSLSupportMode.ClearText;
                RemoteCertificateValidationCallback userValidateServerCertificate;
                userValidateServerCertificate = new RemoteCertificateValidationCallback(ValidateServerCertificate);

                // enable encryption if desired
                if (profile.Encryption.IsTrue())
                {
                    sslSupportMode |= ESSLSupportMode.ControlAndDataChannelsRequired | ESSLSupportMode.CredentialsRequired;
                    if (profile.EncryptionImplicit.IsTrue())
                    {
                        // implicit if desired
                        sslSupportMode |= ESSLSupportMode.Implicit;
                    }
                    if (profile.ForceEncryption.IsTrue())
                    {
                        // force encryption if desired
                        userValidateServerCertificate = new RemoteCertificateValidationCallback(delegate { return true; });
                    }
                }

                session.Connect(profile.Hostname, new System.Net.NetworkCredential(profile.Username, profile.Password), sslSupportMode, userValidateServerCertificate);

                // Upload files
                //TransferOptions transferOptions = new TransferOptions();
                //transferOptions.TransferMode = TransferMode.Binary;

                //TransferOperationResult transferResult;
                //transferResult = session.PutFiles(Path.Combine(temppath, "*"), Common.Parse(remotedir), false, transferOptions);

                try
                {
                    session.SetCurrentDirectory(Common.ParseTemplate(remotedir));
                }
                catch
                {
                    session.MakeDir(Common.ParseTemplate(remotedir));
                }
                session.PutFiles(temppath, Common.ParseTemplate(remotedir), "*", EPatternStyle.Wildcard, false, new FileTransferCallback(TransferCallback));

                // Throw on any error
                //transferResult.Check();

                // Print results
                //foreach (TransferEventArgs transfer in transferResult.Transfers)
                //{
                //    Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
                //}
            }
        }
开发者ID:mard,项目名称:Uploader,代码行数:58,代码来源:Upload.cs

示例14: SslTcpSession

 /// <summary>
 /// 表示SSL客户端会话对象
 /// </summary>  
 /// <param name="targetHost">目标主机</param>
 /// <param name="certificateValidationCallback">远程证书验证回调</param>
 /// <exception cref="ArgumentNullException"></exception>
 public SslTcpSession(string targetHost, RemoteCertificateValidationCallback certificateValidationCallback)
 {
     if (string.IsNullOrEmpty(targetHost) == true)
     {
         throw new ArgumentNullException("targetHost");
     }
     this.targetHost = targetHost;
     this.certificateValidationCallback = certificateValidationCallback;
 }
开发者ID:cityjoy,项目名称:NetworkSocket,代码行数:15,代码来源:SslTcpSession.cs

示例15: SslCertificateValidator

        public SslCertificateValidator(bool acceptAll, string[] validHashes)
        {
            m_acceptAll = acceptAll;
            m_validHashes = validHashes;
            m_oldCallback = System.Net.ServicePointManager.ServerCertificateValidationCallback;

            System.Net.ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertficate);
            m_isAttached = true;
        }
开发者ID:thekrugers,项目名称:duplicati,代码行数:9,代码来源:SslCertificateValidator.cs


注:本文中的RemoteCertificateValidationCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。