-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
61 lines (51 loc) · 1.58 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"crypto/tls"
"fmt"
"log"
"net/http"
"os"
)
func main() {
// Create HTTP server with autocert TLS configuration
cert, err := tls.LoadX509KeyPair("TLS CERT HERE", "TLS CERT KEY HERE")
if err != nil {
fmt.Println("Failed to load SSL certificate and key pair:", err)
return
}
// Create TLS configuration with the loaded certificate and key pair
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
}
// Create HTTPS server with custom TLS configuration
s := &http.Server{
Addr: ":443",
Handler: http.NewServeMux(),
TLSConfig: tlsConfig,
}
// Create a new ServeMux for handling requests
mux := http.NewServeMux()
mux.HandleFunc("/.well-known/webfinger", func(w http.ResponseWriter, r *http.Request) {
log.Printf("Received request: %s %s\n", r.Method, r.URL.Path)
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{
"subject" : "acct:[email protected]",
"links" :
[
{
"rel" : "http://openid.net/specs/connect/1.0/issuer",
"href" : "OCID ISSUER URL HERE"
}
]
}`))
})
// Register the ServeMux as the handler for the HTTPS server
s.Handler = mux
// Configure logger to output to console
log.SetOutput(os.Stdout)
// Start the HTTP server with TLS
err = s.ListenAndServeTLS("", "")
if err != nil {
fmt.Println("Failed to start HTTPS server:", err)
}
}