mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-13 05:45:41 +08:00
Use byte field for certificate data.
This commit is contained in:
@@ -1,13 +1,11 @@
|
|||||||
package certificates
|
package certificates
|
||||||
|
|
||||||
import (
|
import ()
|
||||||
"crypto/x509"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Certificate struct {
|
type Certificate struct {
|
||||||
UUID string `db:"certificate_uuid" json:"uuid"`
|
UUID string `db:"certificate_uuid" json:"uuid"`
|
||||||
DeviceUUID string `db:"device_uuid" json:"device_uuid"`
|
DeviceUUID string `db:"device_uuid" json:"device_uuid"`
|
||||||
Data x509.Certificate `db:"data" json:"data"`
|
Data []byte `db:"data" json:"data"`
|
||||||
CommonName string `db:"common_name" json:"common_nane"`
|
CommonName string `db:"common_name" json:"common_nane"`
|
||||||
IsIdentity bool `db:"is_identity" json:"is_identity"`
|
IsIdentity bool `db:"is_identity" json:"is_identity"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package connect
|
package connect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/x509"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -252,11 +253,19 @@ func (svc service) ackCertificateList(req mdm.Response) error {
|
|||||||
return errors.Wrap(err, "getting a device record by udid")
|
return errors.Wrap(err, "getting a device record by udid")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var certData *x509.Certificate
|
||||||
for _, cert := range req.CertificateList {
|
for _, cert := range req.CertificateList {
|
||||||
|
|
||||||
|
if certData, err = x509.ParseCertificate(cert.Data); err != nil {
|
||||||
|
return errors.Wrap(err, "decoding device certificate")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("%s\n", certData.Subject)
|
||||||
|
|
||||||
newCert := certificates.Certificate{
|
newCert := certificates.Certificate{
|
||||||
CommonName: cert.CommonName,
|
CommonName: cert.CommonName,
|
||||||
IsIdentity: cert.IsIdentity,
|
IsIdentity: cert.IsIdentity,
|
||||||
//Data: cert.Data,
|
Data: cert.Data,
|
||||||
DeviceUUID: device.UUID,
|
DeviceUUID: device.UUID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user