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 關注
- 179 瀏覽
添加回答
舉報