Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to SecTrustEvaulateWihError to avoid deprecation warning #95

Closed
wants to merge 1 commit into from

Conversation

ropnop
Copy link

@ropnop ropnop commented Oct 27, 2021

Hi there! Building smimesign or certstore currently displays a deprecation warning (#85):

# github.com/github/smimesign/certstore
cgo-gcc-prolog:473:11: warning: 'SecTrustEvaluate' is deprecated: first deprecated in macOS 10.15 [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrust.h:353:10: note: 'SecTrustEvaluate' has been explicitly marked deprecated here

I dove into this and this is what I came up with.

SecTrustEvaluate has been marked as deprecated and should be replaced by SecTrustEvaluateWithError according to https://developer.apple.com/documentation/security/1394363-sectrustevaluate

The new function, SecTrustEvaluateWithError returns a bool if the certificate is trusted or not, which I don't believe we care about or need here. It optionally takes a reference to a CFError as well, in which I pass in nil (but we could capture/parse it if we think it's necessary). According to the docs, to make a determination if the failure is recoverable, the docs say to make a call to SecTrustGetTrustResult and evaluate that OSStatus result.

I've modified the code to call SecTrustEvaluateWithError followed by a call to SecTrustGetTrustResult and detemine if that error is recoverable or not. The tests are all passing and I haven't noticed any side effects other than the deprecation warning being gone :)

Let me know if you think this is an acceptable PR!

@vcsjones
Copy link
Member

Sorry for the slow response here. This got addressed by PR #127 and #149, so I am going to close this out.

Thank you for taking the time to address the issue though.

@vcsjones vcsjones closed this Sep 17, 2024
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.

2 participants