update ios cert config.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
76c71b5c9f
commit
5ce2a8e2ca
|
@ -1,5 +1,10 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
)
|
||||
|
||||
var (
|
||||
PushConf ConfYaml
|
||||
CertificatePemIos tls.Certificate
|
||||
)
|
||||
|
|
15
main.go
15
main.go
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
"log"
|
||||
"net/http"
|
||||
"github.com/sideshow/apns2/certificate"
|
||||
)
|
||||
|
||||
func AbortWithError(c *gin.Context, code int, message string) {
|
||||
|
@ -55,11 +56,13 @@ func GetMainEngine() *gin.Engine {
|
|||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
|
||||
// set default parameters
|
||||
// set default parameters.
|
||||
PushConf = BuildDefaultPushConf()
|
||||
|
||||
config, err := LoadConfYaml("config.yaml")
|
||||
// load user define config.
|
||||
PushConf, err = LoadConfYaml("config.yaml")
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Unable to load config file: '%v'", err)
|
||||
|
@ -67,7 +70,13 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
PushConf = config
|
||||
CertificatePemIos, err = certificate.FromPemFile(PushConf.Ios.PemKeyPath, "")
|
||||
|
||||
if err != nil {
|
||||
log.Println("Cert Error:", err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
endless.ListenAndServe(":"+PushConf.Core.Port, GetMainEngine())
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"github.com/google/go-gcm"
|
||||
apns "github.com/sideshow/apns2"
|
||||
"github.com/sideshow/apns2/certificate"
|
||||
"github.com/sideshow/apns2/payload"
|
||||
"log"
|
||||
)
|
||||
|
@ -64,12 +63,7 @@ func pushNotification(notification RequestPushNotification) bool {
|
|||
success bool
|
||||
)
|
||||
|
||||
cert, err := certificate.FromPemFile("./key.pem", "")
|
||||
if err != nil {
|
||||
log.Println("Cert Error:", err)
|
||||
}
|
||||
|
||||
apnsClient := apns.NewClient(cert).Development()
|
||||
apnsClient := apns.NewClient(CertificatePemIos).Development()
|
||||
|
||||
switch notification.Platform {
|
||||
case PlatFormIos:
|
||||
|
|
Loading…
Reference in New Issue