@@ -36,17 +36,21 @@ REALM_NORETURN
36
36
REALM_COLD
37
37
void keychain_access_exception (int32_t error_code)
38
38
{
39
- if (auto message = adoptCF (SecCopyErrorMessageString (error_code, nullptr ))) {
40
- if (auto msg = CFStringGetCStringPtr (message.get (), kCFStringEncodingUTF8 )) {
41
- throw RuntimeError (ErrorCodes::RuntimeError,
42
- util::format (" Keychain returned unexpected status code: %1 (%2)" , msg, error_code));
43
- }
44
- auto length = CFStringGetMaximumSizeForEncoding (CFStringGetLength (message.get ()), kCFStringEncodingUTF8 ) + 1 ;
45
- auto buffer = std::make_unique<char []>(length);
46
- if (CFStringGetCString (message.get (), buffer.get (), length, kCFStringEncodingUTF8 )) {
47
- throw RuntimeError (
48
- ErrorCodes::RuntimeError,
49
- util::format (" Keychain returned unexpected status code: %1 (%2)" , buffer.get (), error_code));
39
+ if (__builtin_available (iOS 11.3 , macOS 10.3 , tvOS 11.3 , watchOS 4.3 , *)) {
40
+ if (auto message = adoptCF (SecCopyErrorMessageString (error_code, nullptr ))) {
41
+ if (auto msg = CFStringGetCStringPtr (message.get (), kCFStringEncodingUTF8 )) {
42
+ throw RuntimeError (
43
+ ErrorCodes::RuntimeError,
44
+ util::format (" Keychain returned unexpected status code: %1 (%2)" , msg, error_code));
45
+ }
46
+ auto length =
47
+ CFStringGetMaximumSizeForEncoding (CFStringGetLength (message.get ()), kCFStringEncodingUTF8 ) + 1 ;
48
+ auto buffer = std::make_unique<char []>(length);
49
+ if (CFStringGetCString (message.get (), buffer.get (), length, kCFStringEncodingUTF8 )) {
50
+ throw RuntimeError (
51
+ ErrorCodes::RuntimeError,
52
+ util::format (" Keychain returned unexpected status code: %1 (%2)" , buffer.get (), error_code));
53
+ }
50
54
}
51
55
}
52
56
throw RuntimeError (ErrorCodes::RuntimeError,
0 commit comments