支持 私有自签证书

This commit is contained in:
bjdgyc
2024-04-22 14:40:03 +08:00
parent 26483533a9
commit 5e804a3483
5 changed files with 29 additions and 14 deletions

View File

@@ -1,13 +1,16 @@
package handler
import (
"crypto/sha1"
"crypto/tls"
"encoding/hex"
"fmt"
"io"
"net"
"net/http"
"net/http/httputil"
"os"
"strings"
"time"
"github.com/bjdgyc/anylink/base"
@@ -36,6 +39,19 @@ func startTls() {
// certs[0], err = tls.LoadX509KeyPair(certFile, keyFile)
// }
tlscert, _, err := dbdata.ParseCert()
if err != nil {
base.Fatal("证书加载失败", err)
}
dbdata.LoadCertificate(tlscert)
// 计算证书hash值
s1 := sha1.New()
s1.Write(tlscert.Certificate[0])
h2s := hex.EncodeToString(s1.Sum(nil))
certHash = strings.ToUpper(h2s)
base.Info("certHash", certHash)
// 修复 CVE-2016-2183
// https://segmentfault.com/a/1190000038486901
// nmap -sV --script ssl-enum-ciphers -p 443 www.example.com