⚡ HTTP/2 Apple Push Notification Service (APNs) push provider for Go — Send push notifications to iOS, tvOS, Safari and OSX apps, using the APNs HTTP/2 protocol.
MIT License
3.01k
stars
335
forks
source link
certificate.FromPem* cannot parse PKCS#8 format #100
package main
import "fmt"
import "github.com/sideshow/apns2/certificate"
import "os"
func main() {
apnsCert, err := certificate.FromPemFile(os.Args[1], "")
if err != nil {
fmt.Printf("Unable to read your certificate: %v\n", err)
} else {
fmt.Printf("Parsed certificate: %v\n", apnsCert)
}
}
openssl pkcs12 -in Certificates.p12 -out testcertificate.pem -nodes -clcerts
go run main.go testcertificate.pem
What did you expect to see?
A parsed certificate.
What did you see instead?
$ go run main.go testcertificate.pem
Error parsing private key asn1: structure error: tags don't match (2 vs {class:0 tag:16 length:13 isCompound:true}) {optional:false explicit:false application:false defaultValue:<nil> tag:<nil> stringType:0 timeType:0 set:false omitEmpty:false} @5
Unable to read your certificate: failed to parse PKCS1 private key
What version of Go are you using?
$ go version
go version go1.9.1 darwin/amd64
Notes
I opened a Stack Overflow question attempting to resolve this. The issue appears to be that sideshow/apns2/certificate assumes the private key to be in PKCS#1 format, whereas openssl pkcs12 generates a file with a private key in PKCS#8 format. I suggest that this lib should be able to parse PKCS#8 format, too.
What did you do?
What did you expect to see?
A parsed certificate.
What did you see instead?
What version of Go are you using?
Notes
I opened a Stack Overflow question attempting to resolve this. The issue appears to be that
sideshow/apns2/certificate
assumes the private key to be in PKCS#1 format, whereasopenssl pkcs12
generates a file with a private key in PKCS#8 format. I suggest that this lib should be able to parse PKCS#8 format, too.