mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-12 04:55:39 +08:00
committed by
Victor Vrantchan
parent
08528c207e
commit
0dc1a18eea
@@ -1,29 +0,0 @@
|
||||
package enroll
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"golang.org/x/crypto/pkcs12"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
const PushTopicASN1 string = "0.9.2342.19200300.100.1.1"
|
||||
|
||||
func GetPushTopicFromPKCS12(certPath string, certPass string) (string, error) {
|
||||
certData, err := ioutil.ReadFile(certPath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
_, cert, err := pkcs12.Decode(certData, certPass)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for _, v := range cert.Subject.Names {
|
||||
if v.Type.String() == PushTopicASN1 {
|
||||
return v.Value.(string), nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", errors.New("Could not find Push Topic in the provided pkcs12 bundle.")
|
||||
}
|
||||
@@ -10,13 +10,9 @@ type Service interface {
|
||||
Enroll(ctx context.Context) (Profile, error)
|
||||
}
|
||||
|
||||
func NewService(pushCertPath, pushCertPass, caCertPath, scepURL, scepChallenge, url, tlsCertPath, scepSubject string) (Service, error) {
|
||||
pushTopic, err := GetPushTopicFromPKCS12(pushCertPath, pushCertPass)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func NewService(pushTopic, caCertPath, scepURL, scepChallenge, url, tlsCertPath, scepSubject string) (Service, error) {
|
||||
var caCert, tlsCert []byte
|
||||
var err error
|
||||
|
||||
if caCertPath != "" {
|
||||
caCert, err = ioutil.ReadFile(caCertPath)
|
||||
|
||||
Reference in New Issue
Block a user