.net 弹跳城堡-过时的LegacyTlsClient
我想用以下代码创建一个带有Bouncy Castle的TlsClient.net 弹跳城堡-过时的LegacyTlsClient,.net,bouncycastle,.net,Bouncycastle,我想用以下代码创建一个带有Bouncy Castle的TlsClient public SecureTcpClient(string host, int port) : this(host, port, new LegacyTlsClient(new AlwaysValidVerifyer())) { } 然而,这个类LegacyTlsClient已经过时了,但我对BouncyCastle的了解还不足以修复这个问题。应该使用哪个类来替换LegacyTlsClient。您应该直接使用D
public SecureTcpClient(string host, int port)
: this(host, port, new LegacyTlsClient(new AlwaysValidVerifyer()))
{
}
然而,这个类LegacyTlsClient已经过时了,但我对BouncyCastle的了解还不足以修复这个问题。应该使用哪个类来替换LegacyTlsClient。您应该直接使用DefaultTlsClient类,如下所示:
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
}
}
有一个DefaultTlsClient没有被弃用,但它看起来必须实现,因为它是抽象的。还有一个PSKTlsClient和一个SRPTlsClient,它们都是抽象的。