猿问

当服务器尝试发送 Expo 通知时,得到“x.509 证书由未知机构签名”

当我尝试向 Expo Push Notification 服务器发送通知时,我收到“x.509 certificate signed by unknown authority”错误消息。


我用 Golang 编写的服务器存储了 expo 推送令牌。然后,它加载这些令牌并构建列表并使用函数expo.PushMessage推送它们。PublishMultiple


我有两台服务器,一台用于测试,另一台用于生产。它在测试服务器中运行良好。我在测试手机上收到了推送通知。所以,我更新了我的生产服务器,然后生产服务器产生x.509 certificate signed by unknown authority消息。


首先,我怀疑我的 expo 推送令牌已损坏,但是当我使用Expo 推送通知工具时推送令牌运行良好。


我不确定在哪里寻找解决方案。谁能帮我?如果您想了解我的服务器代码或设置,我会修改问题。目前,我不确定应该提供哪部分代码或设置来找到解决方案。


以下代码是唯一可能发生错误的地方。


import (

    expo "github.com/oliveroneill/exponent-server-sdk-golang/sdk"

    "github.com/pkg/errors"

)


type Client struct {

    PushClient *expo.PushClient

}


func NewClient() *Client {

    client := expo.NewPushClient(nil)


    return &Client{PushClient: client}

}


func (c *Client) PushNotifications(deviceKeys []string, title string, body string) (error, map[string]string) {

    messages := make([]expo.PushMessage, 0)

    for _, deviceKey := range deviceKeys {

        pushToken, err := expo.NewExponentPushToken(deviceKey)

        if err != nil {

            continue

        }


        messages = append(messages, expo.PushMessage{

            To:        pushToken,

            Body:      body,

            Data:      nil,

            Sound:     "default",

            Title:     title,

            Priority:  expo.DefaultPriority,

            ChannelID: "default",

        })

    }


    // This is only place the error can occur

    // PublishMultiple function is a part of the Expo SDK

    responses, err := c.PushClient.PublishMultiple(messages)

    if err != nil {

        return errors.WithStack(err), nil

    }


    sentErrors := make(map[string]string)

    for index, response := range responses {

        err := response.ValidateResponse()

        if err != nil && index >= len(deviceKeys) {

            sentErrors[deviceKeys[index]] = err.Error()

        }

    }


    return nil, sentErrors

}



梦里花落0921
浏览 191回答 1
1回答

慕村225694

golang:*-alpine图像故意最小化,并且没有系统证书池。最简单的解决方案是在构建 docker 镜像时自己添加:RUN apk add --no-cache ca-certificates
随时随地看视频慕课网APP

相关分类

Go
我要回答