Skip to content

How to use TLS / HTTPS? #97

@mattjohnsonpint

Description

@mattjohnsonpint

Consider a small program:

package main

import (
	"fmt"
	"net/http"

	_ "github.com/stealthrocket/net/http"
)

func main() {
	resp, err := http.Get("https://example.com")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}

	fmt.Println("Status:", resp.Status)
}

Build and run with wasi-go:

GOOS=wasip1 GOARCH=wasm go build --tags getaddrinfo -o app.wasm
wasmrun app.wasm

Result:

Error: Get "https://example.com": tls: failed to verify certificate: x509: certificate signed by unknown authority

If I manually add the root certificates using a package like github.com/breml/rootcerts, then it works. Is that a requirement? Or is there some way to configure wasi-go to use the host's root certificates? I did try --dir=/ but that didn't help. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions