From 2a6289ecf68df87abffe1371bee9f1a3afe10ecf Mon Sep 17 00:00:00 2001
From: xljiulang <366193849@qq.com>
Date: Sun, 18 Sep 2022 01:19:42 +0800
Subject: [PATCH] dotnet7
---
Directory.Build.props | 2 +-
.../FastGithub.Configuration.csproj | 2 +-
.../FastGithub.DomainResolve.csproj | 10 +++----
FastGithub.Http/FastGithub.Http.csproj | 3 +-
FastGithub.Http/HttpClientHandler.cs | 28 ++++---------------
FastGithub.HttpServer/Certs/CertService.cs | 6 ++--
.../FastGithub.HttpServer.csproj | 2 +-
.../FastGithub.PacketIntercept.csproj | 3 +-
FastGithub/FastGithub.csproj | 10 +++----
9 files changed, 22 insertions(+), 44 deletions(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index eea3576a..64b3a6cf 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -2,7 +2,7 @@
2.1.4
enable
- net6.0
+ net7.0
true
github加速神器
https://github.com/dotnetcore/FastGithub
diff --git a/FastGithub.Configuration/FastGithub.Configuration.csproj b/FastGithub.Configuration/FastGithub.Configuration.csproj
index 4afc5f05..c18dd9e7 100644
--- a/FastGithub.Configuration/FastGithub.Configuration.csproj
+++ b/FastGithub.Configuration/FastGithub.Configuration.csproj
@@ -1,7 +1,7 @@
-
+
diff --git a/FastGithub.DomainResolve/FastGithub.DomainResolve.csproj b/FastGithub.DomainResolve/FastGithub.DomainResolve.csproj
index 4caca5a6..7ae4c7a0 100644
--- a/FastGithub.DomainResolve/FastGithub.DomainResolve.csproj
+++ b/FastGithub.DomainResolve/FastGithub.DomainResolve.csproj
@@ -1,11 +1,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/FastGithub.Http/FastGithub.Http.csproj b/FastGithub.Http/FastGithub.Http.csproj
index 93653c3c..e621b9ac 100644
--- a/FastGithub.Http/FastGithub.Http.csproj
+++ b/FastGithub.Http/FastGithub.Http.csproj
@@ -1,7 +1,6 @@
-
-
+
diff --git a/FastGithub.Http/HttpClientHandler.cs b/FastGithub.Http/HttpClientHandler.cs
index f7f5ec8b..61310bb5 100644
--- a/FastGithub.Http/HttpClientHandler.cs
+++ b/FastGithub.Http/HttpClientHandler.cs
@@ -1,7 +1,6 @@
using FastGithub.Configuration;
using FastGithub.DomainResolve;
using System;
-using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -200,32 +199,15 @@ private async IAsyncEnumerable GetIPEndPointsAsync(DnsEndPoint dnsEn
///
private static IEnumerable ReadDnsNames(X509Certificate? cert)
{
- if (cert == null)
+ if (cert is X509Certificate2 x509)
{
- yield break;
- }
- var parser = new Org.BouncyCastle.X509.X509CertificateParser();
- var x509Cert = parser.ReadCertificate(cert.GetRawCertData());
- var subjects = x509Cert.GetSubjectAlternativeNames();
- if (subjects == null)
- {
- yield break;
- }
-
- foreach (var subject in subjects)
- {
- if (subject is IList list)
+ var extension = x509.Extensions.OfType().FirstOrDefault();
+ if (extension != null)
{
- if (list.Count >= 2 && list[0] is int nameType && nameType == 2)
- {
- var dnsName = list[1]?.ToString();
- if (dnsName != null)
- {
- yield return dnsName;
- }
- }
+ return extension.EnumerateDnsNames();
}
}
+ return Array.Empty();
}
///
diff --git a/FastGithub.HttpServer/Certs/CertService.cs b/FastGithub.HttpServer/Certs/CertService.cs
index 7296fa80..9ae1abe9 100644
--- a/FastGithub.HttpServer/Certs/CertService.cs
+++ b/FastGithub.HttpServer/Certs/CertService.cs
@@ -70,12 +70,10 @@ public bool CreateCaCertIfNotExists()
var subjectName = new X500DistinguishedName($"CN={nameof(FastGithub)}");
this.caCert = CertGenerator.CreateCACertificate(subjectName, notBefore, notAfter);
- var privateKey = this.caCert.GetRSAPrivateKey()?.ExportRSAPrivateKey();
- var privateKeyPem = PemEncoding.Write("RSA PRIVATE KEY", privateKey);
+ var privateKeyPem = this.caCert.GetRSAPrivateKey()?.ExportRSAPrivateKeyPem();
File.WriteAllText(this.CaKeyFilePath, new string(privateKeyPem), Encoding.ASCII);
- var cert = this.caCert.Export(X509ContentType.Cert);
- var certPem = PemEncoding.Write("CERTIFICATE", cert);
+ var certPem = this.caCert.ExportCertificatePem();
File.WriteAllText(this.CaCerFilePath, new string(certPem), Encoding.ASCII);
return true;
diff --git a/FastGithub.HttpServer/FastGithub.HttpServer.csproj b/FastGithub.HttpServer/FastGithub.HttpServer.csproj
index d5c76a3c..339d9569 100644
--- a/FastGithub.HttpServer/FastGithub.HttpServer.csproj
+++ b/FastGithub.HttpServer/FastGithub.HttpServer.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj b/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj
index 51be4f4b..508720b7 100644
--- a/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj
+++ b/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj
@@ -6,8 +6,7 @@
-
-
+
diff --git a/FastGithub/FastGithub.csproj b/FastGithub/FastGithub.csproj
index 6aeb733b..57ea9e41 100644
--- a/FastGithub/FastGithub.csproj
+++ b/FastGithub/FastGithub.csproj
@@ -9,8 +9,8 @@
-
-
+
+
@@ -18,10 +18,10 @@
-
-
+
+
-
+