示例#1
0
func newPusher(c Config) (Pusher, error) {
	var (
		cert    tls.Certificate
		errCert error
	)
	if c.CertificateFileName != nil && *c.CertificateFileName != "" {
		cert, errCert = certificate.FromP12File(*c.CertificateFileName, *c.CertificatePassword)
	} else {
		cert, errCert = certificate.FromP12Bytes(*c.CertificateBytes, *c.CertificatePassword)
	}
	if errCert != nil {
		return nil, errCert
	}
	if *c.Production {
		logger.Debug("APNS Pusher in Production mode")
		return apns2.NewClient(cert).Production(), nil
	}
	logger.Debug("APNS Pusher in Development mode")
	return apns2.NewClient(cert).Development(), nil
}
示例#2
0
func TestValidCertificateFromP12Bytes(t *testing.T) {
	bytes, _ := ioutil.ReadFile("_fixtures/certificate-valid.p12")
	cer, err := certificate.FromP12Bytes(bytes, "")
	assert.NoError(t, err)
	assert.Nil(t, verifyHostname(cer))
}