Add feature to have chrome ignore certificate errors when printing using an URL.

This commit is contained in:
Tom van den Berg
2020-06-01 15:31:36 +02:00
parent d28221aec9
commit 24cbe98ac2
4 changed files with 33 additions and 9 deletions

View File

@@ -40,6 +40,8 @@ const (
// DefaultGoogleChromeRpccBufferSizeEnvVar contains the name
// of the environment variable "DEFAULT_GOOGLE_CHROME_RPCC_BUFFER_SIZE".
DefaultGoogleChromeRpccBufferSizeEnvVar string = "DEFAULT_GOOGLE_CHROME_RPCC_BUFFER_SIZE"
// Allow self signed certificates when using a remote url
URLIgnoreCertificateErrorsEnvVar string = "URL_IGNORE_CERTIFICATE_ERRORS"
)
// Config contains the application
@@ -53,6 +55,7 @@ type Config struct {
defaultListenPort int64
disableGoogleChrome bool
disableUnoconv bool
urlIgnoreCertificateErrors bool
logLevel xlog.Level
rootPath string
maximumGoogleChromeRpccBufferSize int64
@@ -75,6 +78,7 @@ func DefaultConfig() Config {
rootPath: "/",
maximumGoogleChromeRpccBufferSize: 104857600, // ~100 MB
defaultGoogleChromeRpccBufferSize: 1048576, // 1 MB
urlIgnoreCertificateErrors: false,
}
}
@@ -188,6 +192,14 @@ func FromEnv() (Config, error) {
if err != nil {
return c, err
}
urlIgnoreCertificateErrors, err := xassert.BoolFromEnv(
URLIgnoreCertificateErrorsEnvVar,
c.urlIgnoreCertificateErrors,
)
c.urlIgnoreCertificateErrors = urlIgnoreCertificateErrors
if err != nil {
return c, err
}
return c, nil
}
result, err := resolver()
@@ -274,3 +286,10 @@ func (c Config) MaximumGoogleChromeRpccBufferSize() int64 {
func (c Config) DefaultGoogleChromeRpccBufferSize() int64 {
return c.defaultGoogleChromeRpccBufferSize
}
// IgnoreCertificateErrors returns true if
// Google Chrome should ignore certificate errors
// in case of self signed certificates for example.
func (c Config) IgnoreCertificateErrors() bool {
return c.urlIgnoreCertificateErrors
}