InsecureSkipVerify and other improvements for the gemini fetch example code
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
45c2beece0
commit
c754a44064
|
@ -30,7 +30,7 @@ func main() {
|
|||
}
|
||||
|
||||
// parse the URL and build the request
|
||||
request := &sr.Request{URL: buildURL()}
|
||||
request := &sr.Request{URL: buildURL(os.Args[1])}
|
||||
|
||||
// fetch the response
|
||||
response, err := client.RoundTrip(request)
|
||||
|
@ -43,17 +43,16 @@ func main() {
|
|||
log.Fatalf("%d %s\n", response.Status, response.Meta)
|
||||
}
|
||||
|
||||
//io.Copy(os.Stdout, response)
|
||||
buf, err := io.ReadAll(gemini.NewResponseReader(response))
|
||||
fmt.Printf("response: %s\n", buf)
|
||||
if _, err := io.Copy(os.Stdout, response.Body); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func envConfig() (string, string) {
|
||||
return os.Getenv("SERVER_CERTIFICATE"), os.Getenv("SERVER_PRIVATEKEY")
|
||||
return os.Getenv("CLIENT_CERTIFICATE"), os.Getenv("CLIENT_PRIVATEKEY")
|
||||
}
|
||||
|
||||
func buildURL() *url.URL {
|
||||
raw := os.Args[1]
|
||||
func buildURL(raw string) *url.URL {
|
||||
if strings.HasPrefix(raw, "//") {
|
||||
raw = "gemini:" + raw
|
||||
}
|
||||
|
|
|
@ -43,7 +43,12 @@ func (client Client) RoundTrip(request *sr.Request) (*sr.Response, error) {
|
|||
host = net.JoinHostPort(host, "1965")
|
||||
}
|
||||
|
||||
conn, err := tls.Dial("tcp", host, client.tlsConf)
|
||||
tlsConf := tls.Config{InsecureSkipVerify: true}
|
||||
if (client.tlsConf != nil) {
|
||||
tlsConf = *client.tlsConf
|
||||
}
|
||||
|
||||
conn, err := tls.Dial("tcp", host, &tlsConf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue