本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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}.");
}
}
示例6: MailClient
protected MailClient(string host, int port, bool isSsl, RemoteCertificateValidationCallback validate)
{
HostName = host;
PortNo = port;
IsSsl = isSsl;
Validate = validate;
}
示例7: SslStream
public SslStream(
NetworkStream innerStream,
bool leaveInnerStreamOpen,
RemoteCertificateValidationCallback userCertificateValidationCallback
) : base(innerStream, leaveInnerStreamOpen, userCertificateValidationCallback)
{
}
示例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);
}
示例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;
}
示例10: TcpClientAdapter
internal TcpClientAdapter()
{
_sendQueue = new Queue<SendState>();
_sendCallback = new AsyncCallback(sendHandler);
_receiveCallback = new AsyncCallback(receiveHandler);
_certCallback = new RemoteCertificateValidationCallback(ValidateCert);
}
示例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);
}
示例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;
}
示例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);
//}
}
}
示例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;
}
示例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;
}