Skip to content

Commit d56f231

Browse files
committed
Simplify error management in getExpirationDate
1 parent 9494f25 commit d56f231

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

certificates/install_darwin.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,11 @@ const char *getExpirationDate(long *expirationDate) {
107107
(id)kSecReturnRef: @YES,
108108
};
109109
110-
OSStatus err = noErr;
111110
SecCertificateRef cert = NULL;
112111
113112
// Search the keychain for certificates matching the query above.
114-
err = SecItemCopyMatching((CFDictionaryRef)getquery, (CFTypeRef *)&cert);
115-
if (err != noErr){
116-
NSString *errString = [@"Error: " stringByAppendingFormat:@"%d", err];
117-
NSLog(@"%@", errString);
118-
return [errString cStringUsingEncoding:[NSString defaultCStringEncoding]];
119-
}
113+
OSStatus err = SecItemCopyMatching((CFDictionaryRef)getquery, (CFTypeRef *)&cert);
114+
if (err != noErr) return toErrorString([@"Error getting the certificate: " stringByAppendingFormat:@"%d", err]);
120115
121116
// Get data from the certificate, as a dictionary of properties. We just need the "invalidity not after" property.
122117
CFDictionaryRef certDict = SecCertificateCopyValues(cert,

0 commit comments

Comments
 (0)