Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let apns support multi-cert #288

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lbeeon
Copy link

@lbeeon lbeeon commented Sep 27, 2017

I modified sort of the code, let the ios could support multiple certifications. The usage was same as the andriod platform. Make a request as followed

{
  "notifications": [
    {
      "tokens": ["token_a", "token_b"],
      "platform": 1,
      "message": "Hello World iOS!",
      "apns_client": "cert1",
    }
  ]
}

key "apns_client" will find the source from config.yaml.
Certificaton can set in config.yaml as followed

ios:
  key_map:
    cert1: "key.pem"
    cert2: "cert2.pem"
    cert3: "cert3.pem"
  key_password:
    cert1: ""
    cert2: ""
    cert3: ""

#99

@janekolszak
Copy link

Hi! What's up with this change?

@kemotes
Copy link

kemotes commented Nov 23, 2017

Yeah, it would be good to have this change. The alternative is to setup 2 or more GoRush instances.

@itsnotvalid
Copy link

Totally agreed to support multiple certs and multiple API keys.

Copy link

@niveuseverto niveuseverto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There one error in code, I marked it

@@ -22,10 +22,13 @@ func InitAPNSClient(key string) (*apns.Client, error) {
LogError.Errorf("Key %s key_password not exist", key)
return nil, errors.New("APNS key_password not exists")
}
path = PushConf.Ios.KeyMap[key]
password = PushConf.Ios.KeyMap[key]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

password = PushConf.Ios.KeyMap[key] needs to be changed to password = PushConf.Ios.KeyPass[key]

@mxpv
Copy link

mxpv commented Mar 26, 2018

I would suggest

ios:
  keys:
  - cert: "key.pem"
    password: ""
  - cert: "cert2.pem"
    password: ""
  - cert: "cert3.pem"
    password: ""

intead of

ios:
  key_map:
    cert1: "key.pem"
    cert2: "cert2.pem"
    cert3: "cert3.pem"
  key_password:
    cert1: ""
    cert2: ""
    cert3: ""

@Struik
Copy link

Struik commented May 23, 2018

@appleboy Hey there
Is there any chance this will be merged or any other way of supporting multiple apns certificated will be implemented?

Copy link
Contributor

@slimus slimus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think empty key InitAPNSClient("") is bad idea.

}
if _, ok := PushConf.Ios.KeyMap[key]; !ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeyMap -> KeyPass

return nil, errors.New("APNS key_password not exists")
}
path = PushConf.Ios.KeyMap[key]
password = PushConf.Ios.KeyMap[key]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeyPass

default:
err = errors.New("wrong certificate key extension")
func InitAPNSClient(key string) (*apns.Client, error) {
path, password := "", ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if PushConf.Ios.Enabled is false?

@@ -56,6 +62,7 @@ func queueNotification(req RequestPush) (int, []LogPushEntry) {
notification.log = &log
notification.AddWaitCount()
}
fmt.Println("-----")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line

@appleboy appleboy force-pushed the master branch 2 times, most recently from 60a7a68 to 2c29b4b Compare June 30, 2022 15:02
@appleboy appleboy force-pushed the master branch 4 times, most recently from bff0f2d to 6b6ef69 Compare December 24, 2022 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants