Skip to content

Instantly share code, notes, and snippets.

@groob groob/pem.go
Created Nov 21, 2017

Embed
What would you like to do?
package main
import (
"fmt"
"log"
"os"
"github.com/groob/plist"
)
type Profile struct {
PayloadContent []PayloadContent `plist:"PayloadContent"`
}
type PayloadContent struct {
PayloadIdentifier string
pem *PEMCert
}
type PEMCert struct {
Password string
PayloadCertificateFileName string
PayloadContent string
PayloadIdentifier string
PayloadUUID string
}
func (p *PayloadContent) UnmarshalPlist(f func(i interface{}) error) error {
var id = struct {
PayloadIdentifier string
}{}
if err := f(&id); err != nil {
return err
}
fmt.Println(id.PayloadIdentifier) // prints the ID
var pem PEMCert
if err := f(&pem); err != nil {
return err
}
p.pem = &pem
return nil
}
func main() {
f, err := os.Open("/Users/victor/Desktop/com.apple.security.pem.mobileconfig")
if err != nil {
log.Fatal(err)
}
defer f.Close()
var p Profile
if err := plist.NewDecoder(f).Decode(&p); err != nil {
log.Fatal(err)
}
fmt.Println(p.PayloadContent[0].pem)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.