mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-13 05:45:41 +08:00
SCEP request subject is configurable and you can use it with templated SCEP variables like %SerialNumber% etc. (#45)
SCEP request subject configurable via flag --scep-subject or environment MICROMDM_SCEP_SUBJECT
This commit is contained in:
25
service.go
25
service.go
@@ -3,13 +3,14 @@ package enroll
|
|||||||
import (
|
import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service interface {
|
type Service interface {
|
||||||
Enroll(ctx context.Context) (Profile, error)
|
Enroll(ctx context.Context) (Profile, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewService(pushCertPath string, pushCertPass string, caCertPath string, scepURL string, scepChallenge string, url string, tlsCertPath string) (Service, error) {
|
func NewService(pushCertPath, pushCertPass, caCertPath, scepURL, scepChallenge, url, tlsCertPath, scepSubject string) (Service, error) {
|
||||||
pushTopic, err := GetPushTopicFromPKCS12(pushCertPath, pushCertPass)
|
pushTopic, err := GetPushTopicFromPKCS12(pushCertPath, pushCertPass)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -33,19 +34,25 @@ func NewService(pushCertPath string, pushCertPass string, caCertPath string, sce
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scepSubject := [][][]string{
|
if scepSubject == "" {
|
||||||
[][]string{
|
scepSubject = "/O=MicroMDM/CN=MicroMDM Identity (%ComputerName%)"
|
||||||
[]string{"O", "MicroMDM"},
|
}
|
||||||
},
|
|
||||||
[][]string{
|
subjectElements := strings.Split(scepSubject, "/")
|
||||||
[]string{"CN", "MDM Identity Certificate UDID"},
|
var subject [][][]string
|
||||||
},
|
|
||||||
|
for _, element := range subjectElements {
|
||||||
|
if element == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
subjectKeyValue := strings.Split(element, "=")
|
||||||
|
subject = append(subject, [][]string{[]string{subjectKeyValue[0], subjectKeyValue[1]}})
|
||||||
}
|
}
|
||||||
|
|
||||||
return &service{
|
return &service{
|
||||||
URL: url,
|
URL: url,
|
||||||
SCEPURL: scepURL,
|
SCEPURL: scepURL,
|
||||||
SCEPSubject: scepSubject,
|
SCEPSubject: subject,
|
||||||
SCEPChallenge: scepChallenge,
|
SCEPChallenge: scepChallenge,
|
||||||
Topic: pushTopic,
|
Topic: pushTopic,
|
||||||
CACert: caCert,
|
CACert: caCert,
|
||||||
|
|||||||
Reference in New Issue
Block a user