mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-08-06 05:08:28 +02:00

+ Added default CA feature + Fixed RWD issue in TLS cert table + Optimized ACME UI in the TLS page
57 lines
1.0 KiB
Go
57 lines
1.0 KiB
Go
package acme
|
|
|
|
/*
|
|
CA.go
|
|
|
|
This script load CA defination from embedded ca.json
|
|
*/
|
|
import (
|
|
_ "embed"
|
|
"encoding/json"
|
|
"errors"
|
|
"log"
|
|
"strings"
|
|
)
|
|
|
|
// CA Defination, load from embeded json when startup
|
|
type CaDef struct {
|
|
Production map[string]string
|
|
Test map[string]string
|
|
}
|
|
|
|
//go:embed ca.json
|
|
var caJson []byte
|
|
|
|
var caDef CaDef = CaDef{}
|
|
|
|
func init() {
|
|
runtimeCaDef := CaDef{}
|
|
err := json.Unmarshal(caJson, &runtimeCaDef)
|
|
if err != nil {
|
|
log.Println("[ERR] Unable to unmarshal CA def from embedded file. You sure your ca.json is valid?")
|
|
return
|
|
}
|
|
|
|
caDef = runtimeCaDef
|
|
}
|
|
|
|
// Get the CA ACME server endpoint and error if not found
|
|
func loadCAApiServerFromName(caName string) (string, error) {
|
|
// handle BuyPass cert org section (Buypass AS-983163327)
|
|
if strings.HasPrefix(caName, "Buypass AS") {
|
|
caName = "Buypass"
|
|
}
|
|
|
|
val, ok := caDef.Production[caName]
|
|
if !ok {
|
|
return "", errors.New("This CA is not supported")
|
|
}
|
|
|
|
return val, nil
|
|
}
|
|
|
|
func IsSupportedCA(caName string) bool {
|
|
_, err := loadCAApiServerFromName(caName)
|
|
return err == nil
|
|
}
|