chore: upgrade apns2 version

This commit is contained in:
Bo-Yi Wu 2018-05-21 10:01:00 +08:00
parent 672ac28d8f
commit b94a538d7b
2 changed files with 19 additions and 14 deletions

View File

@ -17,7 +17,7 @@ import (
// Possible errors when parsing a certificate. // Possible errors when parsing a certificate.
var ( var (
ErrFailedToDecryptKey = errors.New("failed to decrypt private key") ErrFailedToDecryptKey = errors.New("failed to decrypt private key")
ErrFailedToParsePKCS1PrivateKey = errors.New("failed to parse PKCS1 private key") ErrFailedToParsePrivateKey = errors.New("failed to parse private key")
ErrFailedToParseCertificate = errors.New("failed to parse certificate PEM data") ErrFailedToParseCertificate = errors.New("failed to parse certificate PEM data")
ErrNoPrivateKey = errors.New("no private key") ErrNoPrivateKey = errors.New("no private key")
ErrNoCertificate = errors.New("no certificate") ErrNoCertificate = errors.New("no certificate")
@ -26,7 +26,7 @@ var (
// FromP12File loads a PKCS#12 certificate from a local file and returns a // FromP12File loads a PKCS#12 certificate from a local file and returns a
// tls.Certificate. // tls.Certificate.
// //
// Use "" as the password argument if the pem certificate is not password // Use "" as the password argument if the PKCS#12 certificate is not password
// protected. // protected.
func FromP12File(filename string, password string) (tls.Certificate, error) { func FromP12File(filename string, password string) (tls.Certificate, error) {
p12bytes, err := ioutil.ReadFile(filename) p12bytes, err := ioutil.ReadFile(filename)
@ -120,9 +120,14 @@ func unencryptPrivateKey(block *pem.Block, password string) (crypto.PrivateKey,
} }
func parsePrivateKey(bytes []byte) (crypto.PrivateKey, error) { func parsePrivateKey(bytes []byte) (crypto.PrivateKey, error) {
var key crypto.PrivateKey
key, err := x509.ParsePKCS1PrivateKey(bytes) key, err := x509.ParsePKCS1PrivateKey(bytes)
if err != nil { if err == nil {
return nil, ErrFailedToParsePKCS1PrivateKey
}
return key, nil return key, nil
}
key, err = x509.ParsePKCS8PrivateKey(bytes)
if err == nil {
return key, nil
}
return nil, ErrFailedToParsePrivateKey
} }

10
vendor/vendor.json vendored
View File

@ -451,16 +451,16 @@
"versionExact": "v0.13" "versionExact": "v0.13"
}, },
{ {
"checksumSHA1": "c3x81Xq+gIn5JBgs1eCTVeRwDDo=", "checksumSHA1": "EHOwwdWPJGt1vNVeJxyRDRHBhl8=",
"path": "github.com/sideshow/apns2/certificate", "path": "github.com/sideshow/apns2/certificate",
"revision": "c23f4b07d9e47aa490ff76001001decc688243f8", "revision": "c6554aff77e6e5580dec977c8c33cc238f329ab0",
"revisionTime": "2017-01-05T14:10:18Z" "revisionTime": "2018-04-13T21:53:35Z"
}, },
{ {
"checksumSHA1": "9Lxz0w+q8pqp/Do/kNa8hLoQeY0=", "checksumSHA1": "9Lxz0w+q8pqp/Do/kNa8hLoQeY0=",
"path": "github.com/sideshow/apns2/payload", "path": "github.com/sideshow/apns2/payload",
"revision": "c23f4b07d9e47aa490ff76001001decc688243f8", "revision": "c6554aff77e6e5580dec977c8c33cc238f329ab0",
"revisionTime": "2017-01-05T14:10:18Z" "revisionTime": "2018-04-13T21:53:35Z"
}, },
{ {
"checksumSHA1": "nkQ/1JoIY4jh8XlI8LClfFVux9U=", "checksumSHA1": "nkQ/1JoIY4jh8XlI8LClfFVux9U=",