Skip to content

Commit

Permalink
Add ability to use .p file
Browse files Browse the repository at this point in the history
  • Loading branch information
Kay-Zee committed Sep 29, 2017
1 parent a6b20e5 commit d69bdbe
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions gorush/notification_apns.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ func InitAPNSClient() error {
CertificatePemIos, err = certificate.FromP12File(PushConf.Ios.KeyPath, PushConf.Ios.Password)
case ".pem":
CertificatePemIos, err = certificate.FromPemFile(PushConf.Ios.KeyPath, PushConf.Ios.Password)
case ".p8":
authKey, err := token.AuthKeyFromFile(PushConf.Ios.KeyPath)
if err != nil {
LogError.Error("P8 Error:", err.Error())
return err
}
token := &token.Token{
AuthKey: authKey,
// KeyID from developer account (Certificates, Identifiers & Profiles -> Keys)
KeyID: PushConf.Ios.KeyID,
// TeamID from developer account (View Account -> Membership)
TeamID: PushConf.Ios.TeamID,
}
ApnsClient = apns.NewTokenClient(token)
return nil
default:
err = errors.New("wrong certificate key extension")
}
Expand Down

0 comments on commit d69bdbe

Please sign in to comment.