由未知授权机构签署的x509证书 [英] x509 certificate signed by unknown authority

查看:113
本文介绍了由未知授权机构签署的x509证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试一些基本示例,以从Web请求数据,但是对不同主机的所有请求均会导致SSL错误: x509:未知授权机构签署的证书.注意:我没有使用代理,也没有发生任何形式的证书拦截,因为使用curl或浏览器都可以正常工作.

I'm trying some basic examples to request data from the web, however all requests to different hosts result in an SSL error: x509: certificate signed by unknown authority. Note: I'm not behind a proxy and no forms of certificate interception is happening, as using curl or the browser works without problems.

我目前正在使用的代码示例是:

The code sample I'm currently working with is:

package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
    "os"
    )

func main() {
    response, err := http.Get("https://google.com")
    if err != nil {
        fmt.Printf("%s\n", err)
        os.Exit(1)
    } else {
        defer response.Body.Close()
        contents, err := ioutil.ReadAll(response.Body)
        if err != nil {
            fmt.Printf("%s", err)
            os.Exit(1)
        }
        fmt.Printf("%s\n", string(contents))
    }
}

代码在Arch Linux内核4.9.37-1-lts上运行.

Code is run on Arch linux kernel 4.9.37-1-lts.

编辑2 :显然,(code)/etc/ssl/certs/ca-certificates.crt 在我系统上的版本之间存在差异,方法是(移走)了证书并手动重新安装 ca-certificates-utils 软件包,此问题已解决.

Edit 2: Apparently /etc/ssl/certs/ca-certificates.crt had a difference between the version on my system, by (re)moving the certificate and re-installing the ca-certificates-utils package manually, the issue was solved.

推荐答案

基于您的错误,我假设您使用的是Linux?

Based on your error, I'm assuming you are using Linux?

您可能必须在运行程序的计算机上安装ca证书.

It's likely that you will have to install ca-certificates on the machine your program is running on.

在Ubuntu上,您将执行以下操作:

On Ubuntu, you would execute something like this:

sudo apt-get install ca-certificates

这篇关于由未知授权机构签署的x509证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆