mirror of
https://github.com/gosticks/simplecert.git
synced 2026-10-05 14:16:54 +00:00
added support for wildcard certificates
This commit is contained in:
+2
-1
@@ -13,4 +13,5 @@
|
||||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
|
||||
.glide/
|
||||
|
||||
letsencrypt
|
||||
letsencrypt
|
||||
simplecert
|
||||
@@ -14,5 +14,5 @@ func main() {
|
||||
w.Write([]byte("hello"))
|
||||
})
|
||||
|
||||
log.Fatal(simplecert.ListenAndServeTLSLocal(":443", nil, "myawesomewebsite.com"))
|
||||
log.Fatal(simplecert.ListenAndServeTLSLocal(":443", nil, "*.myawesomewebsite.com"))
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/lextoumbourou/goodhosts"
|
||||
)
|
||||
@@ -57,13 +58,21 @@ func createLocalCert(certFilePath, keyFilePath string) {
|
||||
var (
|
||||
newCertFile string
|
||||
newKeyFile string
|
||||
|
||||
firstDomain = c.Domains[0]
|
||||
)
|
||||
|
||||
if strings.HasPrefix(firstDomain, "*") {
|
||||
firstDomain = strings.TrimPrefix(firstDomain, "*")
|
||||
firstDomain = "_wildcard" + firstDomain
|
||||
}
|
||||
|
||||
if len(c.Domains) > 1 {
|
||||
newCertFile = c.Domains[0] + "+" + strconv.Itoa(len(c.Domains)-1) + ".pem"
|
||||
newKeyFile = c.Domains[0] + "+" + strconv.Itoa(len(c.Domains)-1) + "-key.pem"
|
||||
newCertFile = firstDomain + "+" + strconv.Itoa(len(c.Domains)-1) + ".pem"
|
||||
newKeyFile = firstDomain + "+" + strconv.Itoa(len(c.Domains)-1) + "-key.pem"
|
||||
} else {
|
||||
newCertFile = c.Domains[0] + ".pem"
|
||||
newKeyFile = c.Domains[0] + "-key.pem"
|
||||
newCertFile = firstDomain + ".pem"
|
||||
newKeyFile = firstDomain + "-key.pem"
|
||||
}
|
||||
|
||||
// rename certificate file
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
2019/02/21 17:35:31 [INFO] simplecert: checking if cacheDir simplecert/local exists...
|
||||
2019/02/21 17:35:31 [INFO] simplecert: cacheDir does not exist - creating it
|
||||
2019/02/21 17:35:31 [INFO] no cached cert found. Creating a new one for local development...
|
||||
2019/02/21 17:35:34 [INFO] renaming myawesomewebsite.com.pem to simplecert/local/cert.pem
|
||||
2019/02/21 17:35:34 [INFO] renaming myawesomewebsite.com-key.pem to simplecert/local/key.pem
|
||||
2019/02/21 17:35:34 starting HTTP Listener on Port 80
|
||||
2019/02/21 17:35:34 serving: https://myawesomewebsite.com
|
||||
2019/02/21 17:35:45 [INFO] simplecert: checking if cacheDir simplecert/local exists...
|
||||
2019/02/21 17:35:45 starting HTTP Listener on Port 80
|
||||
2019/02/21 17:35:45 serving: https://myawesomewebsite.com
|
||||
Reference in New Issue
Block a user