bogdanfinn / tls-client

net/http.Client like HTTP Client with options to select specific client TLS Fingerprints to use for requests.
BSD 4-Clause "Original" or "Old" License
667 stars 133 forks source link

[Bug]: undefined: tls.UtlsExtendedMasterSecretExtension #76

Closed seadhy closed 9 months ago

seadhy commented 9 months ago

TLS client version

1.6.1

Issue description

image

Steps to reproduce / Code Sample

// your example code
package main

import (
    "fmt"
    "io"
    "log"

    http "github.com/bogdanfinn/fhttp"
    tls_client "github.com/bogdanfinn/tls-client"
    "github.com/bogdanfinn/tls-client/profiles"
)

func main() {
    jar := tls_client.NewCookieJar()
    options := []tls_client.HttpClientOption{
        tls_client.WithTimeoutSeconds(30),
        tls_client.WithClientProfile(profiles.Chrome_105),
        tls_client.WithNotFollowRedirects(),
        tls_client.WithCookieJar(jar), // create cookieJar instance and pass it as argument
    }

    client, err := tls_client.NewHttpClient(tls_client.NewNoopLogger(), options...)
    if err != nil {
        log.Println(err)
        return
    }

    req, err := http.NewRequest(http.MethodGet, "https://tls.peet.ws/api/all", nil)
    if err != nil {
        log.Println(err)
        return
    }

    req.Header = http.Header{
        "accept":          {"*/*"},
        "accept-language": {"de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"},
        "user-agent":      {"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"},
        http.HeaderOrderKey: {
            "accept",
            "accept-language",
            "user-agent",
        },
    }

    resp, err := client.Do(req)
    if err != nil {
        log.Println(err)
        return
    }

    defer resp.Body.Close()

    log.Println(fmt.Sprintf("status code: %d", resp.StatusCode))

    readBytes, err := io.ReadAll(resp.Body)
    if err != nil {
        log.Println(err)
        return
    }

    log.Println(string(readBytes))
}
bogdanfinn commented 9 months ago

@seadhy can you quickly double check the version of the utls package in your go.mod file? It should be github.com/bogdanfinn/utls v1.5.16

Just change the version and do a go mod tidy