Merge pull request #94 from appleboy/password
Fixed #93 Support password parameter when loads a PEM certificate fro…
This commit is contained in:
commit
77fc6699bd
|
@ -71,6 +71,7 @@ android:
|
||||||
ios:
|
ios:
|
||||||
enabled: false
|
enabled: false
|
||||||
pem_path: "key.pem"
|
pem_path: "key.pem"
|
||||||
|
password: "" # certificate password, default as empty string.
|
||||||
production: false
|
production: false
|
||||||
|
|
||||||
log:
|
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).
|
* `-i`: Apple Push Notification Certificate path (`pem` file).
|
||||||
* `-t`: Device token.
|
* `-t`: Device token.
|
||||||
* `-topic`: The topic of the remote notification.
|
* `-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.
|
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 {
|
type SectionIos struct {
|
||||||
Enabled bool `yaml:"enabled"`
|
Enabled bool `yaml:"enabled"`
|
||||||
PemPath string `yaml:"pem_path"`
|
PemPath string `yaml:"pem_path"`
|
||||||
|
Password string `yaml:"password"`
|
||||||
Production bool `yaml:"production"`
|
Production bool `yaml:"production"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +107,7 @@ func BuildDefaultPushConf() ConfYaml {
|
||||||
// iOS
|
// iOS
|
||||||
conf.Ios.Enabled = false
|
conf.Ios.Enabled = false
|
||||||
conf.Ios.PemPath = "key.pem"
|
conf.Ios.PemPath = "key.pem"
|
||||||
|
conf.Ios.Password = ""
|
||||||
conf.Ios.Production = false
|
conf.Ios.Production = false
|
||||||
|
|
||||||
// log
|
// log
|
||||||
|
|
|
@ -21,6 +21,7 @@ android:
|
||||||
ios:
|
ios:
|
||||||
enabled: false
|
enabled: false
|
||||||
pem_path: "key.pem"
|
pem_path: "key.pem"
|
||||||
|
password: ""
|
||||||
production: false
|
production: false
|
||||||
|
|
||||||
log:
|
log:
|
||||||
|
|
|
@ -23,6 +23,7 @@ func main() {
|
||||||
version := flag.Bool("v", false, "gorush version")
|
version := flag.Bool("v", false, "gorush version")
|
||||||
confPath := flag.String("c", "", "yaml configuration file path for gorush")
|
confPath := flag.String("c", "", "yaml configuration file path for gorush")
|
||||||
certificateKeyPath := flag.String("i", "", "iOS certificate key 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")
|
apiKey := flag.String("k", "", "Android api key configuration for gorush")
|
||||||
port := flag.String("p", "", "port number for gorush")
|
port := flag.String("p", "", "port number for gorush")
|
||||||
token := flag.String("t", "", "token string")
|
token := flag.String("t", "", "token string")
|
||||||
|
@ -61,6 +62,11 @@ func main() {
|
||||||
gorush.PushConf.Ios.PemPath = *certificateKeyPath
|
gorush.PushConf.Ios.PemPath = *certificateKeyPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *certificatePassword != "" {
|
||||||
|
log.Printf("Load yaml config file error: '%v'", certificatePassword)
|
||||||
|
gorush.PushConf.Ios.Password = *certificatePassword
|
||||||
|
}
|
||||||
|
|
||||||
if *apiKey != "" {
|
if *apiKey != "" {
|
||||||
gorush.PushConf.Android.APIKey = *apiKey
|
gorush.PushConf.Android.APIKey = *apiKey
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ func InitAPNSClient() error {
|
||||||
if PushConf.Ios.Enabled {
|
if PushConf.Ios.Enabled {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
CertificatePemIos, err = certificate.FromPemFile(PushConf.Ios.PemPath, "")
|
CertificatePemIos, err = certificate.FromPemFile(PushConf.Ios.PemPath, PushConf.Ios.Password)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogError.Error("Cert Error:", err.Error())
|
LogError.Error("Cert Error:", err.Error())
|
||||||
|
|
Loading…
Reference in New Issue