weixin_39571404
2021-01-11 10:24Debian SSLStream Exception
Hi,
I have SSL exception when call AuthenticateAsClient on several web site on Debian 9. Work fine on windows 10.
Follow the test case (VS 2017 15.5.2): TestSSLStream.zip
c#
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
namespace TestSSLStream
{
class Program
{
static void Main(string[] args)
{
Uri uri = new Uri(args[0]);
IPHostEntry dns = Dns.Resolve(uri.Host);
using (TcpClient client = new TcpClient())
{
client.Connect(/*dns.AddressList[0]*/uri.Host, uri.Port);
client.ReceiveTimeout = 10000;
using (SslStream sslStream = new SslStream(client.GetStream(), false))
{
sslStream.AuthenticateAsClient(uri.Host);
// Check certificate
string expirationDate = sslStream.RemoteCertificate.GetExpirationDateString();
StreamWriter writer = new StreamWriter(sslStream);
writer.Write("GET " + uri.AbsolutePath + " HTTP/1.1\r\n");
writer.Write("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n");
writer.Write("Accept-Encoding: gzip, deflate\r\n");
writer.Write("Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3\r\n");
writer.Write("User-Agent: Mozilla/5.0 (compatible; TestBot; TEST)\r\n");
writer.Write("Connection: close\r\n");
writer.Write("Host: " + uri.Host + "\r\n\r\n");
writer.Flush();
StreamReader reader = new StreamReader(sslStream);
string response = reader.ReadToEnd();
}
}
}
}
}
On debian:
dotnet --info
Microsoft .NET Core Shared Framework Host
Version : 2.0.4 Build : 7f262f453d8c8479b9af91d34c013b3aa05bc1ff
On debian, Exception when execute:
dotnet TestSSLStream.dll https://korben.info/ dotnet TestSSLStream.dll https://www.toutvendre.fr
work fine with certificate of github:
dotnet TestSSLStream.dll https://github.com
All certificate are not managed on debian 9 with ssl stream?
[EDIT] Added C# code from the zip file
该提问来源于开源项目:dotnet/runtime
- 点赞
- 回答
- 收藏
- 复制链接分享
8条回答
为你推荐
- 在Debian中怎么下载.rpm文件
- unix
- linux
- centos
- ubuntu
- 1个回答
- 如何在Debian中将简单的Go服务器作为守护程序运行?
- server
- linux
- debian
- 1个回答
- 在Debian上通过pecl安装apcu失败
- debian
- pear
- php
- 1个回答
- wkhtmltopdf没有为Debian创建pdf
- debian
- wkhtmltopdf
- php
- 2个回答
- 在Debian上安装php7.1-bcmath
- debian
- php
- 1个回答
换一换