From 14f3bc2fe23cf2da22c144d9529d90b25aca67df Mon Sep 17 00:00:00 2001 From: hiddify <114227601+hiddify-com@users.noreply.github.com> Date: Sun, 29 Sep 2024 10:46:12 +0200 Subject: [PATCH] fix: windows build --- utils/certificate_wi.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/utils/certificate_wi.go b/utils/certificate_wi.go index 0926346..24684e8 100644 --- a/utils/certificate_wi.go +++ b/utils/certificate_wi.go @@ -16,7 +16,16 @@ import ( "time" ) -func GenerateCertificate(certPath, keyPath string, isServer bool) { +func fileExists(path string) bool { + _, err := os.Stat(path) + return !os.IsNotExist(err) // returns true if the file exists +} + +func GenerateCertificate(certPath, keyPath string, isServer bool, skipIfExist bool) { + if skipIfExist && fileExists(certPath) && fileExists(keyPath) { + return + } + priv, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader) if err != nil { panic(err)