• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RemoteCertificateValidationCallback类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: connect

        private void connect(string host, int port, bool isSsl, RemoteCertificateValidationCallback validate)
        {
            if (_client == null)
            {
                _client = new TcpClient { ReceiveTimeout = 20000 };
            }

            if (!_client.Connected)
            {
                try
                {
                    _client.Connect(host, port);
                }
                catch (SocketException ex)
                {
                    var retVal = string.Empty;
                    switch (ex.ErrorCode)
                    {
                        case 11001: // Host not found.
                            retVal = ex.Message;
                            break;
                        case 10060: //Connection timed out.  (invalid portNo) (yahoo,hotmail and indiatimes)
                        case 10061: //Connection refused.
                        case 10013: // Permission denied. from hotmail
                            retVal = "Invalid host or port number";
                            break;
                        default:
                            retVal = "Invalid host or port number";
                            break;
                    }

                    throw new Exception(retVal);
                }
            }

            if (_client.Connected)
            {
                _stream = _client.GetStream();
                if (isSsl)
                {
                    try
                    {
                        var sslStream = new SslStream(_stream, false, validate ?? ((sender, cert, chain, err) => true));
                        sslStream.AuthenticateAsClient(host);
                        _stream = sslStream;
                    }
                    catch(Exception)
                    {
                        throw;
                    }
                }

                var response = ReadResponse();

                ValidateResponse(response);
            }
        }
开发者ID:hmanjarawala,项目名称:GitRepo,代码行数:57,代码来源:EmailClient.cs


示例17: DotNetSslStreamImpl

		public DotNetSslStreamImpl (
			Stream innerStream, bool leaveInnerStreamOpen,
			RemoteCertificateValidationCallback userCertificateValidationCallback,
			LocalCertificateSelectionCallback userCertificateSelectionCallback)
		{
			impl = new SslStream (
				innerStream, leaveInnerStreamOpen,
				userCertificateValidationCallback,
				userCertificateSelectionCallback);
		}
开发者ID:JokerGITHUB,项目名称:mono,代码行数:10,代码来源:DotNetSslStreamImpl.cs


示例18: HTTPSClient

 /// <summary>
 /// Create a new HTTPClient using the given optional parameters.
 /// </summary>
 /// <param name="RemoteSocket">The remote IP socket to connect to.</param>
 /// <param name="RemoteCertificateValidator">A delegate to verify the remote TLS certificate.</param>
 /// <param name="ClientCert">The TLS client certificate to use.</param>
 /// <param name="DNSClient">An optional DNS client.</param>
 public HTTPSClient(IPSocket                             RemoteSocket,
                    RemoteCertificateValidationCallback  RemoteCertificateValidator,
                    X509Certificate                      ClientCert  = null,
                    DNSClient                            DNSClient   = null)
     : base(RemoteSocket,
            RemoteCertificateValidator,
            ClientCert,
            DNSClient)
 {
 }
开发者ID:Vanaheimr,项目名称:Hermod,代码行数:17,代码来源:HTTPSClient.cs


示例19: SslProxy

        /// <summary>
        ///     Creates new instance of <see cref="HttpProxy" /> using provided default port and internal buffer size.
        /// </summary>
        /// <param name="defaultPort">
        ///     Port number on destination server which will be used if not specified in request
        /// </param>
        /// <param name="certificate">
        ///     Certificate used for server authentication
        /// </param>
        /// <param name="rcValidationCallback">
        ///     Used to validate destination server certificate. By default it accepts anything provided by server
        /// </param>
        public SslProxy(X509Certificate certificate, Int32 defaultPort,
            RemoteCertificateValidationCallback rcValidationCallback = null)
            : base(defaultPort)
        {
            Contract.Requires<ArgumentNullException>(certificate != null, "certificate");

            _certificateValidationCallback = rcValidationCallback ?? DefaultCertificateValidationCallback;

            _certificate = certificate;
        }
开发者ID:brunoklein99,项目名称:FryProxy,代码行数:22,代码来源:SslProxy.cs


示例20: SslStream

        /// <include file='../../../_Doc/System.xml' path='doc/members/member[@name="M:System.Net.Security.SslStream.#ctor(System.IO.Stream,System.Boolean,System.Net.Security.RemoteCertificateValidationCallback)"]/*' />
        public SslStream(Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
        {
            var tcpClientStream = innerStream as NetworkStream;
            if (tcpClientStream == null)
                throw new ArgumentException("Stream type not associated with TCP client", "innerStream");

            _innerStream = tcpClientStream;
            _leaveInnerStreamOpen = leaveInnerStreamOpen;
            this.userCertificateValidationCallback = userCertificateValidationCallback;
        }
开发者ID:BeeINSIGHT,项目名称:shim,代码行数:11,代码来源:SslStream.Store.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RemoteClient类代码示例发布时间:2022-05-24
下一篇:
C# RemoteAsyncOperation类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap