feat: Let's Encrypt SSL on site creation
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/panelhosting/panel/internal/ssl"
|
||||
)
|
||||
|
||||
type ACMEHandler struct {
|
||||
store *ssl.ChallengeStore
|
||||
}
|
||||
|
||||
func NewACMEHandler(store *ssl.ChallengeStore) *ACMEHandler {
|
||||
return &ACMEHandler{store: store}
|
||||
}
|
||||
|
||||
func (h *ACMEHandler) Challenge(w http.ResponseWriter, r *http.Request) {
|
||||
token := r.PathValue("token")
|
||||
if token == "" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
keyAuth, ok := h.store.Get(token)
|
||||
if !ok {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
_, _ = w.Write([]byte(keyAuth))
|
||||
}
|
||||
Reference in New Issue
Block a user