|
@@ -23,14 +23,14 @@ type Manager struct {
|
|
|
//go:embed localhost.crt localhost.key
|
|
|
var buildinCertStore embed.FS
|
|
|
|
|
|
-func NewManager(certStore string) (*Manager, error) {
|
|
|
+func NewManager(certStore string, verbal bool) (*Manager, error) {
|
|
|
if !utils.FileExists(certStore) {
|
|
|
os.MkdirAll(certStore, 0775)
|
|
|
}
|
|
|
|
|
|
thisManager := Manager{
|
|
|
CertStore: certStore,
|
|
|
- verbal: true,
|
|
|
+ verbal: verbal,
|
|
|
}
|
|
|
|
|
|
return &thisManager, nil
|
|
@@ -115,17 +115,17 @@ func (m *Manager) GetCert(helloInfo *tls.ClientHelloInfo) (*tls.Certificate, err
|
|
|
return &cer, nil
|
|
|
}
|
|
|
|
|
|
-//Check if both the default cert public key and private key exists
|
|
|
+// Check if both the default cert public key and private key exists
|
|
|
func (m *Manager) DefaultCertExists() bool {
|
|
|
return utils.FileExists(filepath.Join(m.CertStore, "default.crt")) && utils.FileExists(filepath.Join(m.CertStore, "default.key"))
|
|
|
}
|
|
|
|
|
|
-//Check if the default cert exists returning seperate results for pubkey and prikey
|
|
|
+// Check if the default cert exists returning seperate results for pubkey and prikey
|
|
|
func (m *Manager) DefaultCertExistsSep() (bool, bool) {
|
|
|
return utils.FileExists(filepath.Join(m.CertStore, "default.crt")), utils.FileExists(filepath.Join(m.CertStore, "default.key"))
|
|
|
}
|
|
|
|
|
|
-//Delete the cert if exists
|
|
|
+// Delete the cert if exists
|
|
|
func (m *Manager) RemoveCert(domain string) error {
|
|
|
pubKey := filepath.Join(m.CertStore, domain+".crt")
|
|
|
priKey := filepath.Join(m.CertStore, domain+".key")
|
|
@@ -146,7 +146,7 @@ func (m *Manager) RemoveCert(domain string) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-//Check if the given file is a valid TLS file
|
|
|
+// Check if the given file is a valid TLS file
|
|
|
func IsValidTLSFile(file io.Reader) bool {
|
|
|
// Read the contents of the uploaded file
|
|
|
contents, err := io.ReadAll(file)
|