SSL Handshake failure over SOCKS5 connection

280 views Asked by At

I am making a relay between the target server and me, the relay is the SOCKS5 proxy server.

But I do not understand why the SSL handshake fails when sending an HTTPS request, I mean I don't see anything odd in my code.

package main

import (
    "crypto/tls"
    "fmt"
    "io"
    "log"
    "time"

    "github.com/Pix4Devs/pix4lib/socks"
)

func main() {
    proxy := socks.ProxyCtx{
        IP:   "185.199.229.156",
        Port: 7492,
    }
    target := socks.TargetCtx{
        IP:   "google.com",
        Port: 443,
    }

    conn, err := socks.NewSocks5Client(time.Second * 3).Connect(proxy,false, socks.Auth{}, target); if err != nil {
        log.Fatal(err)
    }
    defer conn.Close()

    tlsConn := tls.Client(conn, &tls.Config{InsecureSkipVerify: true})
    if err := tlsConn.Handshake(); err != nil {
        log.Fatal(err)
    }

    if _, err := tlsConn.Write([]byte("GET / HTTP/1.1\r\nHost: google.com\r\nContent-Type: text/html\r\n\r\n")); err != nil {
        log.Fatal(err)
    }

    reply := []byte{}
    buffer := make([]byte, 1024)
    for {
        n, err := tlsConn.Read(buffer)
        if err == io.EOF {
            break
        }
        if err != nil {
            log.Fatal(err)
        }
        reply = append(reply, buffer[:n]...)
    }

    fmt.Println(string(reply))
}
0

There are 0 answers