ufk
ufk

Reputation: 32104

connect to socks5 proxy with IKEv2 certificate using golang 1.10.2

I use Go 1.10.2 for my client application.

I'm trying to connect to a socks5 proxy that requires username, password and IKEv2 certificate file.

this is what I've got so far:

 func socks5(proxyAdress string, url string, user string, password string) {
        auth := proxy.Auth{User: user, Password: password}
        if proxy, err := proxy.SOCKS5("tcp", proxyAdress, &auth, proxy.Direct);  err != nil {
            log.Fatalf("error: %v", proxy)
        } else {
            tr := &http.Transport{Dial: proxy.Dial}

            // Create client
            myClient := &http.Client{
                Transport: tr,
            }

            if resp, err2 := myClient.Get(url); err2 != nil {
                log.Fatalf("error: %v", err2)
            } else {
                if bodyBytes, err3 := ioutil.ReadAll(resp.Body); err3 != nil {
                    log.Fatalf("error: %v", err3)
                } else {
                    str := string(bodyBytes)
                    log.Printf(str)
                }

            }
        }
    }

when I execute this function with the proper parameters

I get an error from the server that I don't have permissions to access the web page I requested. that's because I didn't specify the IKEv2 key file.

so.. first.. how do I do that ?

and 2nd... Dial is deprecated.. I'm supposed to use DialContext but has no idea how

thanks ! :)

update

the OS that I use is MacOS High Sierra 10.13.4

the problem is that for example when I execute

socks5("il7.nordvpn.com:1080", "http://ifconfig.me/ip","MY_USER","MY_PASS")

the error that I get is

2018/05/15 23:34:49 error: Get http://ifconfig.me/ip: socks connect tcp ifconfig.me:80->ifconfig.me:80: EOF

I don't know where to provide the IKEv2 certificate

Upvotes: 4

Views: 1494

Answers (1)

MK Vimalan
MK Vimalan

Reputation: 1288

I think you need to set up IPSec on your computer first.

The steps to setup IPSec

  1. Initial configurations (only once at the first time)
  2. Start a VPN connection

Follow here

Upvotes: 1

Related Questions