No more funny business with InsecureSkipVerify

This commit is contained in:
Sasha Koshka 2023-05-27 03:57:27 -04:00
parent 9025844212
commit 5e37c4bb8f
8 changed files with 28 additions and 46 deletions

View File

@ -3,7 +3,6 @@ package main
import "sync"
import "path"
import "net/http"
import "crypto/tls"
import "html/template"
import "hnakra/service"
@ -28,12 +27,10 @@ func main () {
board.mux = http.NewServeMux()
board.Service = service.Service {
&service.HTTP {
Mount: service.MountConfig {
Path: board.root,
Name: "Board",
Description: "A board where you can post things.",
TLSConfig: &tls.Config { InsecureSkipVerify: true },
},
Mount: service.M (
"Board",
"A board where you can post things.",
"@", board.root),
Handler: board.mux,
},
}

View File

@ -3,7 +3,6 @@ package main
import "fmt"
import "log"
import "net/http"
import "crypto/tls"
import "hnakra/service"
func main () {
@ -11,13 +10,10 @@ func main () {
http.HandleFunc("/gifs/", gifs)
http.Handle("/gifs/static/", http.StripPrefix("/gifs/static", static))
err := (&service.HTTP { Mount: service.MountConfig {
Path: "/gifs/",
Name: "Gifs",
Description: "Serves a lot of big gifs on one page.",
TLSConfig: &tls.Config { InsecureSkipVerify: true },
}}).Run()
err := service.NewHTTP (
"Gifs", "Serves a lot of big gifs on one page.",
"@", "/gifs/").Run()
if err != nil {
log.Println("XXX", err)

View File

@ -2,17 +2,11 @@ package main
import "log"
import "net/http"
import "crypto/tls"
import "hnakra/service"
func main () {
http.HandleFunc("/hello/", hellorld)
err := (&service.HTTP { Mount: service.MountConfig {
Path: "/hello/",
Name: "Hellorld",
Description: "A test service.",
TLSConfig: &tls.Config { InsecureSkipVerify: true },
}}).Run()
err := service.NewHTTP("Hellorld", "A test service.", "@", "/hello/").Run()
if err != nil {
log.Println("XXX", err)

View File

@ -2,7 +2,6 @@ package main
import "log"
import "net/http"
import "crypto/tls"
import "hnakra/service"
func main () {
@ -15,12 +14,9 @@ func main () {
http.ServeFile(res, req, "fractal.png")
})
err := (&service.HTTP { Mount: service.Mount {
Path: "/fractal.png",
Name: "Image",
Description: "Displays an image of a fractal.",
TLSConfig: &tls.Config { InsecureSkipVerify: true },
}}).Run()
err := service.NewHTTP (
"Image",
"Displays an image of a fractal.",
"@", "/fractal.png").Run()
if err != nil { log.Println("XXX", err) }
}

View File

@ -2,21 +2,16 @@ package main
import "log"
import "net/http"
import "crypto/tls"
import "hnakra/service"
func main () {
http.HandleFunc("/kamikaze/", hellorld)
err := (&service.HTTP { Mount: service.MountConfig {
Path: "/kamikaze/",
Name: "Kamikaze",
Description: "A service that abrupltly closes upon any request, for testing",
TLSConfig: &tls.Config { InsecureSkipVerify: true },
}}).Run()
if err != nil {
log.Println("XXX", err)
}
err := service.NewHTTP (
"Kamikaze",
"A service that abrupltly closes upon any request, for testing.",
"@", "/kamikaze/").Run()
if err != nil { log.Println("XXX", err) }
}
func hellorld (res http.ResponseWriter, req *http.Request) {

View File

@ -38,7 +38,6 @@ func (manager *Manager) Run () error {
for _, routine := range manager.Routines {
if routine != nil {
println("yeah")
waitGroup.Add(1)
go manager.runRoutine(routine, &waitGroup, &errExit)
}

View File

@ -90,8 +90,8 @@ func (mount *HTTP) Run () (err error) {
// NewHTTP creates a very basic https:// mount with the specified name and
// description.
func NewHTTP (name, description string) HTTP {
return HTTP { Mount: M(name, description) }
func NewHTTP (name, description, host, path string) *HTTP {
return &HTTP { Mount: M(name, description, host, path) }
}
func (mount *HTTP) send (message protocol.Message) (err error) {

View File

@ -11,8 +11,10 @@ import "encoding/base64"
import "hnakra/protocol"
// M creates a very basic MountConfig with the specified name and description.
func M (name, description string) MountConfig {
func M (name, description, host, path string) MountConfig {
return MountConfig {
Host: host,
Path: path,
Name: name,
Description: description,
}
@ -78,7 +80,10 @@ type MountConfig struct {
// Maximum length: 255 bytes
Key []byte
// TLSConfig is an optional TLS configuration.
// TLSConfig is an optional TLS configuration. If you are looking to
// set InsecureSkipVerify to false, consider instead setting the
// environment variables $SSL_CERT_FILE or $SSL_CERT_DIR to point toward
// a custom root certificate.
TLSConfig *tls.Config
}