充气城堡 - 过时的 LegacyTlsClient
Bouncy Castle - Obsolete LegacyTlsClient
我想使用以下代码创建一个带有 Bouncy Castle 的 TlsClient
public SecureTcpClient(string host, int port)
: this(host, port, new LegacyTlsClient(new AlwaysValidVerifyer()))
{
}
这个 class LegacyTlsClient 已经过时了,但我对 Bouncy Castle 的了解还不足以解决这个问题。 class 应该用来替换 LegacyTlsClient。
你应该直接使用 DefaultTlsClient class,像这样:
class TlsClient : DefaultTlsClient {
public override TlsAuthentication GetAuthentication() {
return new CustomTlsAuthentication();
}
}
class CustomTlsAuthentication : TlsAuthentication {
public TlsCredentials GetClientCredentials(CertificateRequest certificateRequest) {
// return client certificate here if necessary
return null;
}
public void NotifyServerCertificate(Certificate serverCertificate) {
// validate server certificate here
}
}
我想使用以下代码创建一个带有 Bouncy Castle 的 TlsClient
public SecureTcpClient(string host, int port)
: this(host, port, new LegacyTlsClient(new AlwaysValidVerifyer()))
{
}
这个 class LegacyTlsClient 已经过时了,但我对 Bouncy Castle 的了解还不足以解决这个问题。 class 应该用来替换 LegacyTlsClient。
你应该直接使用 DefaultTlsClient class,像这样:
class TlsClient : DefaultTlsClient {
public override TlsAuthentication GetAuthentication() {
return new CustomTlsAuthentication();
}
}
class CustomTlsAuthentication : TlsAuthentication {
public TlsCredentials GetClientCredentials(CertificateRequest certificateRequest) {
// return client certificate here if necessary
return null;
}
public void NotifyServerCertificate(Certificate serverCertificate) {
// validate server certificate here
}
}