Skip to content

Manually verify SHA1 certificates (fixes #854)#855

Merged
jessepeterson merged 2 commits intomicromdm:mainfrom
korylprince:sha1-verify
Jan 24, 2023
Merged

Manually verify SHA1 certificates (fixes #854)#855
jessepeterson merged 2 commits intomicromdm:mainfrom
korylprince:sha1-verify

Conversation

@korylprince
Copy link
Contributor

Per discussions on the macadmins slack, this changes crypto.VerifyFromAppleDeviceCA to use a manual signature verification instead of using Go's x509 library, since SHA1WithRSA is deprecated and planned to be removed from Go.

I also went ahead and stuck the public key in a var so it doesn't have to parse the embedded cert on each call.

@korylprince korylprince linked an issue Jan 24, 2023 that may be closed by this pull request
`

// extracted public key from appleiPhoneDeviceCAPEM
var appleiPhoneDeviceCAPublicKey = &rsa.PublicKey{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep this within the single X.509 PEM that's already in the source. If optimization was the concern we could add an init() function that does the parsing just once at startup time (though I generally dislike them). I know you test for equality in the test but I like the single source of truth better. Thoughts? Could also wrap this into an interface with its own initializer as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the test was sufficient, but I can see how it seems a little "dirty".

I pushed a commit that replaces the handcrafted public key with a "mustParsePublicKey" function. This way, we're still only parsing it once, but we have the single source of truth. Does that work for you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this looks good!

I don't think its "dirty" per se — I just dislike multiple sources of truth. Like if we wanted to update that cert or whatever we only have one place we need to do it. (Though, honestly, if Apple did update that cert we'd probably have to go do something else yet again heh).

Copy link
Member

@jessepeterson jessepeterson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@jessepeterson jessepeterson merged commit 589b8b1 into micromdm:main Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unauthorized enrollment client

2 participants