Skip to content

let apns support multi-cert #288

Open
lbeeon wants to merge 2 commits into
appleboy:masterfrom
lbeeon:multi-certificate
Open

let apns support multi-cert #288
lbeeon wants to merge 2 commits into
appleboy:masterfrom
lbeeon:multi-certificate

Conversation

@lbeeon

@lbeeon lbeeon commented Sep 27, 2017

Copy link
Copy Markdown

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
Copy Markdown

Hi! What's up with this change?

@kemotes

kemotes commented Nov 23, 2017

Copy link
Copy Markdown

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

@itsnotvalid

Copy link
Copy Markdown

Totally agreed to support multiple certs and multiple API keys.

@niveuseverto niveuseverto left a comment

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

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

mxpv commented Mar 26, 2018

Copy link
Copy Markdown

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

Struik commented May 23, 2018

Copy link
Copy Markdown

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

@slimus slimus left a comment

Copy link
Copy Markdown
Contributor

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.

LogError.Errorf("Key %s key_map not exist", key)
return nil, errors.New("APNS key_map not exists")
}
if _, ok := PushConf.Ios.KeyMap[key]; !ok {

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

Comment thread gorush/worker.go
notification.log = &log
notification.AddWaitCount()
}
fmt.Println("-----")

Copy link
Copy Markdown
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