首页 文章

Golang - 跳过SSL / x509验证和构建包吗?

提问于
浏览
1

我对Go语言一无所知,我只想在Ubuntu 14上使用这个应用程序:

在做任何事之前,我不得不set the GOPATH environment variable in my ~/.bashrc . 然后README说这个程序安装有:

go get -u github.com/mvdan/fdroidcl/cmd/fdroidcl

传递正常,找到可执行文件 . 实际上,这些是在家中找到的文件,其中 GOPATH~/go

$ find ~ -name 'fdroidcl*' 2>/dev/null 
/home/myusername/.cache/fdroidcl
/home/myusername/.config/fdroidcl
/home/myusername/go/pkg/gccgo_linux_386/github.com/mvdan/fdroidcl
/home/myusername/go/src/github.com/mvdan/fdroidcl
/home/myusername/go/src/github.com/mvdan/fdroidcl/cmd/fdroidcl
/home/myusername/go/bin/fdroidcl

很好,但现在当我开始初始命令时:

$ fdroidcl updateDownloading https://f-droid.org/repo/index.jar... 
update: could not update index: Get https://f-droid.org/repo/index.jar: x509: certificate signed by unknown authority (possibly because of "x509: cannot verify signature: algorithm unimplemented" while trying to verify candidate authority certificate "COMODO RSA Certification Authority")

这很可能是由于自签名证书而导致的失败 . 快速解决方法是使用 http:// 而不是 https:// (如果 f-droid.org 目前可能),所以我尝试更改 ~/go/src/github.com/mvdan/fdroidcl/cmd/fdroidcl/main.go

var config = userConfig{
        Repos: []repo{
                {
                        ID:      "f-droid",
                        //URL:     "https://f-droid.org/repo",
                        URL:     "http://f-droid.org/repo",
                        Enabled: true,
                },
                {
                        ID:      "f-droid-archive",
                        //URL:     "https://f-droid.org/archive",
                        URL:     "http://f-droid.org/archive",
                        Enabled: false,
                },
        },
}

...但命令实际上是二进制的:

$ file $(which fdroidcl)
~/go/bin/fdroidcl: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=cd1dc87b54f9023983511ef46fda15a4d88dcb2d, not stripped

...这意味着我必须以某种方式从源代码重新构建此应用程序以获得这些更改 - 我将如何做到这一点?

此外,可能还有其他具有自签名https证书的应用程序会破坏,因此我更倾向于跳过SSL / X509验证 . 看来,正如_1563261指出的那样,应该在代码中做:

tr := http.DefaultTransport.(*http.Transport)
tr.TLSClientConfig.InsecureSkipVerify = true

...再次需要黑客攻击/重新编译源代码 - 但是不存在某种环境变量来帮助它,比如GIT_SSL_NO_VERIFY for git

1 回答

  • 2

    像您一样更新源代码(在 $GOPATH/src 中)后,您可以尝试使用以下命令重新编译:

    go install github.com/mvdan/fdroidcl/cmd/fdroidcl
    

相关问题