Skip to content

Commit

Permalink
Removed unused code.
Browse files Browse the repository at this point in the history
  • Loading branch information
getvictor committed Jan 4, 2025
1 parent 3a146c2 commit ef2ea77
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions server/service/mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2546,31 +2546,6 @@ func (svc *Service) GetMDMAppleCSR(ctx context.Context) ([]byte, error) {
return signedCSRB64, nil
}

func parseAPNSPrivateKey(ctx context.Context, block *pem.Block) (crypto.PrivateKey, error) {
if block == nil {
return nil, ctxerr.New(ctx, "failed to decode saved APNS key")
}

// The code below is based on tls.parsePrivateKey
// https://cs.opensource.google/go/go/+/release-branch.go1.23:src/crypto/tls/tls.go;l=355-372
if key, err := x509.ParsePKCS1PrivateKey(block.Bytes); err == nil {
return key, nil
}
if key, err := x509.ParsePKCS8PrivateKey(block.Bytes); err == nil {
switch key := key.(type) {
case *rsa.PrivateKey, *ecdsa.PrivateKey, ed25519.PrivateKey:
return key, nil
default:
return nil, errors.New("unmarshaled PKCS8 APNS key is not an RSA, ECDSA, or Ed25519 private key")
}
}
if key, err := x509.ParseECPrivateKey(block.Bytes); err == nil {
return key, nil
}

return nil, ctxerr.New(ctx, fmt.Sprintf("failed to parse APNS private key of type %s", block.Type))
}

////////////////////////////////////////////////////////////////////////////////
// POST /mdm/apple/apns_certificate
////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit ef2ea77

Please sign in to comment.