mirror of
https://github.com/fatedier/frp.git
synced 2025-05-08 23:48:26 +00:00
Merge e2b34fff62ba7c2e642b07e5d00d7525aaab1f03 into 9d5638cae6dfecb10bff7c6d3e52625fe264fee1
This commit is contained in:
commit
b8a4fbe40b
@ -103,6 +103,7 @@ type HTTP2HTTPSPluginOptions struct {
|
||||
LocalAddr string `json:"localAddr,omitempty"`
|
||||
HostHeaderRewrite string `json:"hostHeaderRewrite,omitempty"`
|
||||
RequestHeaders HeaderOperations `json:"requestHeaders,omitempty"`
|
||||
RootCA string `json:"rootCA,omitempty"`
|
||||
}
|
||||
|
||||
func (o *HTTP2HTTPSPluginOptions) Complete() {}
|
||||
@ -137,6 +138,7 @@ type HTTPS2HTTPSPluginOptions struct {
|
||||
EnableHTTP2 *bool `json:"enableHTTP2,omitempty"`
|
||||
CrtPath string `json:"crtPath,omitempty"`
|
||||
KeyPath string `json:"keyPath,omitempty"`
|
||||
RootCA string `json:"rootCA,omitempty"`
|
||||
}
|
||||
|
||||
func (o *HTTPS2HTTPSPluginOptions) Complete() {
|
||||
|
@ -19,11 +19,13 @@ package plugin
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"io"
|
||||
stdlog "log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"os"
|
||||
|
||||
"github.com/fatedier/golib/pool"
|
||||
|
||||
@ -53,8 +55,23 @@ func NewHTTP2HTTPSPlugin(options v1.ClientPluginOptions) (Plugin, error) {
|
||||
l: listener,
|
||||
}
|
||||
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
tr := &http.Transport{}
|
||||
|
||||
if opts.RootCA != "" {
|
||||
caCert, err := os.ReadFile(opts.RootCA)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
caCertPool, err := x509.SystemCertPool()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
caCertPool.AppendCertsFromPEM(caCert)
|
||||
tr.TLSClientConfig = &tls.Config{
|
||||
RootCAs: caCertPool,
|
||||
}
|
||||
} else {
|
||||
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
}
|
||||
|
||||
rp := &httputil.ReverseProxy{
|
||||
|
@ -19,12 +19,14 @@ package plugin
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io"
|
||||
stdlog "log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/fatedier/golib/pool"
|
||||
@ -58,8 +60,23 @@ func NewHTTPS2HTTPSPlugin(options v1.ClientPluginOptions) (Plugin, error) {
|
||||
l: listener,
|
||||
}
|
||||
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
tr := &http.Transport{}
|
||||
|
||||
if opts.RootCA != "" {
|
||||
caCert, err := os.ReadFile(opts.RootCA)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
caCertPool, err := x509.SystemCertPool()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
caCertPool.AppendCertsFromPEM(caCert)
|
||||
tr.TLSClientConfig = &tls.Config{
|
||||
RootCAs: caCertPool,
|
||||
}
|
||||
} else {
|
||||
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
}
|
||||
|
||||
rp := &httputil.ReverseProxy{
|
||||
|
Loading…
x
Reference in New Issue
Block a user