File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
12
12
"net"
13
13
"net/http"
14
14
"os"
15
+ "runtime"
15
16
"time"
16
17
17
18
"github.com/pkg/errors"
@@ -288,10 +289,20 @@ func getDefaultDialer() *net.Dialer {
288
289
// transport for HTTP/2.
289
290
func getDefaultTransport (tlsConfig * tls.Config ) * http.Transport {
290
291
var dialContext func (ctx context.Context , network string , addr string ) (net.Conn , error )
291
- if mTLSDialContext == nil {
292
+ switch {
293
+ case runtime .GOOS == "js" && runtime .GOARCH == "wasm" :
294
+ // when running in js/wasm and using the default dialer context all requests
295
+ // performed by the CA client resulted in a "protocol not supported" error.
296
+ // By setting the dial context to nil requests will be handled by the browser
297
+ // fetch API instead. Currently this will always set the dial context to nil,
298
+ // but we could implement some additional logic similar to what's found in
299
+ // https://github.com/golang/go/pull/46923/files to support a different dial
300
+ // context if it is available, required and expected to work.
301
+ dialContext = nil
302
+ case mTLSDialContext == nil :
292
303
d := getDefaultDialer ()
293
304
dialContext = d .DialContext
294
- } else {
305
+ default :
295
306
dialContext = mTLSDialContext ()
296
307
}
297
308
return & http.Transport {
You can’t perform that action at this time.
0 commit comments