Created
November 21, 2017 05:37
-
-
Save groob/900733a473091800e84be938e3e28442 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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