mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Skip insecure certificates check when scraping (#1120)
* Ignore insecure certificates when scraping * add ScraperCertCheck to scraper config options
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package scraper
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
stashConfig "github.com/stashapp/stash/pkg/manager/config"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
)
|
||||
@@ -83,6 +85,8 @@ func setMovieBackImage(m *models.ScrapedMovie, globalConfig GlobalConfig) error
|
||||
|
||||
func getImage(url string, globalConfig GlobalConfig) (*string, error) {
|
||||
client := &http.Client{
|
||||
Transport: &http.Transport{ // ignore insecure certificates
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: !stashConfig.GetScraperCertCheck()}},
|
||||
Timeout: imageGetTimeout,
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package scraper
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -22,6 +23,7 @@ import (
|
||||
"golang.org/x/net/publicsuffix"
|
||||
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
stashConfig "github.com/stashapp/stash/pkg/manager/config"
|
||||
)
|
||||
|
||||
// Timeout for the scrape http request. Includes transfer time. May want to make this
|
||||
@@ -49,6 +51,9 @@ func loadURL(url string, scraperConfig config, globalConfig GlobalConfig) (io.Re
|
||||
printCookies(jar, scraperConfig, "Jar cookies set from scraper")
|
||||
|
||||
client := &http.Client{
|
||||
Transport: &http.Transport{ // ignore insecure certificates
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: !stashConfig.GetScraperCertCheck()},
|
||||
},
|
||||
Timeout: scrapeGetTimeout,
|
||||
// defaultCheckRedirect code with max changed from 10 to 20
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
|
||||
Reference in New Issue
Block a user