1

Heroku 不知何故丢失了它的 GeoTrust Global CA 根证书,这是在 Apple 的服务器上使用推送通知所必需的。我在这里找到了证书,但我不确定如何在我的 Heroku 应用程序中安装它。我尝试通过应用程序的设置将其添加为 SSL 证书,但它说我需要一个私钥 - 我在哪里可以获得根证书?还是我应该在其他地方添加这个?

我应该指定我的应用程序是一个 golang 应用程序。

4

3 回答 3

1

我重新定义了 sideshow/apns2 客户端工厂函数以在 rootCA 中包含 GeoTrust CA,并且我在 Heroku 上的应用程序可以访问苹果的 apns 服务器。

const (
    GeoTrustCACert = "<path to GeoTrust_Global_CA.pem>"
)

func newCertPool(certPath string) (*x509.CertPool, error) {
    rootCAs, _ := x509.SystemCertPool()
    if rootCAs == nil {
        rootCAs = x509.NewCertPool()
    }

    certs, err := ioutil.ReadFile(certPath)
    if err != nil {
        return nil, errors.New("no certs appended, using system certs only")
    }

    if ok := rootCAs.AppendCertsFromPEM(certs); !ok {
        log.Println("no certs appended, using systems only certs")
    }
    return rootCAs, nil
}

func NewApns2ClientWithGeoTrustCA(certificate tls.Certificate) *apns2.Client {
    rootCas, err := newCertPool(GeoTrustCACert)
    if err != nil {
        return nil
    }
    tlsConfig := &tls.Config{
        RootCAs:      rootCas,
        Certificates: []tls.Certificate{certificate},
    }

    if len(certificate.Certificate) > 0 {
        tlsConfig.BuildNameToCertificate()
    }
    transport := &http2.Transport{
        TLSClientConfig: tlsConfig,
        DialTLS:         apns2.DialTLS,
    }

    return &apns2.Client{
        HTTPClient: &http.Client{
            Transport: transport,
            Timeout:   apns2.HTTPClientTimeout,
        },
        Certificate: certificate,
        Host:        apns2.DefaultHost,
    }

}

于 2021-02-11T13:50:39.573 回答
0

我们在 Spring Boot 应用程序中也遇到了类似的问题,该应用程序使用工件“pushy”、groupId“com.eatthepath”和“0.14.2”版本的 APN 推送通知并部署在 heroku 中。为了解决这个问题,我们按照以下链接中的步骤操作:https ://help.heroku.com/447CZS8V/why-is-my-java-app-unable-to-find-a-valid-certification-path和https ://devcenter.heroku.com/articles/customizing-the-jdk然后还使用了“CaCertUtil”类和“GeoTrust_Global_CA.pem”文件并添加了“.setTrustedServerCertificateChain(CaCertUtil.allCerts());” 在构建 ApnsClientBuilder 时行。

“CaCertUtil”和“GeoTrust_Global_CA.pem”取自此链接https://github.com/wultra/powerauth-push-server/commit/71abeb5663201fedf64830fa0ebdf4db6c537e4b

于 2021-02-10T14:58:14.087 回答
0

本周我们遇到了类似的问题,并通过直接在 Heroku Dashboard 中向 App 变量添加证书来解决它。根据文档,您还可以再次手动添加 CA。 https://devcenter.heroku.com/articles/ssl

于 2021-02-10T15:01:52.957 回答