3 回答

TA贡献1804条经验 获得超7个赞
我重新定义了sideshow/apns2客户端工厂功能,将GeoTrust CA包含在rootCA中,并且Apple的apns服务器可以访问Heroku上的应用程序。
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,
}
}

TA贡献1821条经验 获得超5个赞
本周我们遇到了类似的问题,并通过直接在 Heroku 仪表板中将证书添加到 App 变量来解决。根据文档,您也可以再次手动添加 CA。https://devcenter.heroku.com/articles/ssl

TA贡献1780条经验 获得超5个赞
我们在春季启动应用程序中也遇到了类似的问题,该应用程序使用工件“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,然后在构建ApnsClientBuilder时还使用了“CaCertUtil”类和“GeoTrust_Global_CA.pem”文件,并添加了“.setTrustedServerCertificateChain(CaCertUtil.allCerts());”行。
“CaCertUtil”和“GeoTrust_Global_CA.pem”取自此链接 https://github.com/wultra/powerauth-push-server/commit/71abeb5663201fedf64830fa0ebdf4db6c537e4b。
- 3 回答
- 0 关注
- 189 浏览
添加回答
举报