mirror of
https://github.com/axllent/mailpit.git
synced 2025-06-02 23:17:48 +02:00
Feature: Option to allow untrusted HTTPS certificates for screenshots & link checking (#204)
This commit is contained in:
parent
74236258db
commit
4c5b024eca
@ -109,6 +109,8 @@ func init() {
|
|||||||
rootCmd.Flags().StringVar(&config.WebhookURL, "webhook-url", config.WebhookURL, "Send a webhook request for new messages")
|
rootCmd.Flags().StringVar(&config.WebhookURL, "webhook-url", config.WebhookURL, "Send a webhook request for new messages")
|
||||||
rootCmd.Flags().IntVar(&webhook.RateLimit, "webhook-limit", webhook.RateLimit, "Limit webhook requests per second")
|
rootCmd.Flags().IntVar(&webhook.RateLimit, "webhook-limit", webhook.RateLimit, "Limit webhook requests per second")
|
||||||
|
|
||||||
|
rootCmd.Flags().BoolVar(&config.AllowUntrustedTLS, "allow-untrusted-tls", config.AllowUntrustedTLS, "Do not verify HTTPS certificates (link checker & screenshots)")
|
||||||
|
|
||||||
rootCmd.Flags().StringVarP(&config.SMTPCLITags, "tag", "t", config.SMTPCLITags, "Tag new messages matching filters")
|
rootCmd.Flags().StringVarP(&config.SMTPCLITags, "tag", "t", config.SMTPCLITags, "Tag new messages matching filters")
|
||||||
rootCmd.Flags().BoolVarP(&logger.QuietLogging, "quiet", "q", logger.QuietLogging, "Quiet logging (errors only)")
|
rootCmd.Flags().BoolVarP(&logger.QuietLogging, "quiet", "q", logger.QuietLogging, "Quiet logging (errors only)")
|
||||||
rootCmd.Flags().BoolVarP(&logger.VerboseLogging, "verbose", "v", logger.VerboseLogging, "Verbose logging")
|
rootCmd.Flags().BoolVarP(&logger.VerboseLogging, "verbose", "v", logger.VerboseLogging, "Verbose logging")
|
||||||
@ -199,6 +201,9 @@ func initConfigFromEnv() {
|
|||||||
if getEnabledFromEnv("MP_BLOCK_REMOTE_CSS_AND_FONTS") {
|
if getEnabledFromEnv("MP_BLOCK_REMOTE_CSS_AND_FONTS") {
|
||||||
config.BlockRemoteCSSAndFonts = true
|
config.BlockRemoteCSSAndFonts = true
|
||||||
}
|
}
|
||||||
|
if getEnabledFromEnv("MP_ALLOW_UNTRUSTED_TLS") {
|
||||||
|
config.AllowUntrustedTLS = true
|
||||||
|
}
|
||||||
if getEnabledFromEnv("MP_QUIET") {
|
if getEnabledFromEnv("MP_QUIET") {
|
||||||
logger.QuietLogging = true
|
logger.QuietLogging = true
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,9 @@ var (
|
|||||||
// ContentSecurityPolicy for HTTP server - set via VerifyConfig()
|
// ContentSecurityPolicy for HTTP server - set via VerifyConfig()
|
||||||
ContentSecurityPolicy string
|
ContentSecurityPolicy string
|
||||||
|
|
||||||
|
// AllowUntrustedTLS allows untrusted HTTPS connections link checking & screenshot generation
|
||||||
|
AllowUntrustedTLS bool
|
||||||
|
|
||||||
// Version is the default application version, updated on release
|
// Version is the default application version, updated on release
|
||||||
Version = "dev"
|
Version = "dev"
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package linkcheck
|
package linkcheck
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
@ -59,8 +60,15 @@ func doHead(link string, followRedirects bool) (int, error) {
|
|||||||
|
|
||||||
timeout := time.Duration(10 * time.Second)
|
timeout := time.Duration(10 * time.Second)
|
||||||
|
|
||||||
|
tr := &http.Transport{}
|
||||||
|
|
||||||
|
if config.AllowUntrustedTLS {
|
||||||
|
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
}
|
||||||
|
|
||||||
client := http.Client{
|
client := http.Client{
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
|
Transport: tr,
|
||||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||||
if followRedirects {
|
if followRedirects {
|
||||||
return nil
|
return nil
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -31,8 +32,15 @@ func ProxyHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr := &http.Transport{}
|
||||||
|
|
||||||
|
if config.AllowUntrustedTLS {
|
||||||
|
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
}
|
||||||
|
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: 10 * time.Second,
|
Transport: tr,
|
||||||
|
Timeout: 10 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", uri, nil)
|
req, err := http.NewRequest("GET", uri, nil)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user