Fixed #93 Support password parameter when loads a PEM certificate from a local file.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
6c5e4ca457
commit
919ffe6726
|
@ -71,6 +71,7 @@ android:
|
|||
ios:
|
||||
enabled: false
|
||||
pem_path: "key.pem"
|
||||
password: "" # certificate password, default as empty string.
|
||||
production: false
|
||||
|
||||
log:
|
||||
|
@ -124,6 +125,7 @@ $ gorush -ios -m="your message" -i="your certificate path" -t="device token" -to
|
|||
* `-i`: Apple Push Notification Certificate path (`pem` file).
|
||||
* `-t`: Device token.
|
||||
* `-topic`: The topic of the remote notification.
|
||||
* `-password`: The certificate password.
|
||||
|
||||
The default endpoint is APNs development. Please add `-production` flag for APNs production push endpoint.
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ type SectionAndroid struct {
|
|||
type SectionIos struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
PemPath string `yaml:"pem_path"`
|
||||
Password string `yaml:"password"`
|
||||
Production bool `yaml:"production"`
|
||||
}
|
||||
|
||||
|
@ -106,6 +107,7 @@ func BuildDefaultPushConf() ConfYaml {
|
|||
// iOS
|
||||
conf.Ios.Enabled = false
|
||||
conf.Ios.PemPath = "key.pem"
|
||||
conf.Ios.Password = ""
|
||||
conf.Ios.Production = false
|
||||
|
||||
// log
|
||||
|
|
|
@ -21,6 +21,7 @@ android:
|
|||
ios:
|
||||
enabled: false
|
||||
pem_path: "key.pem"
|
||||
password: ""
|
||||
production: false
|
||||
|
||||
log:
|
||||
|
|
|
@ -23,6 +23,7 @@ func main() {
|
|||
version := flag.Bool("v", false, "gorush version")
|
||||
confPath := flag.String("c", "", "yaml configuration file path for gorush")
|
||||
certificateKeyPath := flag.String("i", "", "iOS certificate key file path for gorush")
|
||||
certificatePassword := flag.String("password", "", "iOS certificate password for gorush")
|
||||
apiKey := flag.String("k", "", "Android api key configuration for gorush")
|
||||
port := flag.String("p", "", "port number for gorush")
|
||||
token := flag.String("t", "", "token string")
|
||||
|
@ -61,6 +62,11 @@ func main() {
|
|||
gorush.PushConf.Ios.PemPath = *certificateKeyPath
|
||||
}
|
||||
|
||||
if *certificatePassword != "" {
|
||||
log.Printf("Load yaml config file error: '%v'", certificatePassword)
|
||||
gorush.PushConf.Ios.Password = *certificatePassword
|
||||
}
|
||||
|
||||
if *apiKey != "" {
|
||||
gorush.PushConf.Android.APIKey = *apiKey
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ func InitAPNSClient() error {
|
|||
if PushConf.Ios.Enabled {
|
||||
var err error
|
||||
|
||||
CertificatePemIos, err = certificate.FromPemFile(PushConf.Ios.PemPath, "")
|
||||
CertificatePemIos, err = certificate.FromPemFile(PushConf.Ios.PemPath, PushConf.Ios.Password)
|
||||
|
||||
if err != nil {
|
||||
LogError.Error("Cert Error:", err.Error())
|
||||
|
|
Loading…
Reference in New Issue