Permalink
Browse files

Fixed the keyserver check for new gpg.

Search for a non-existing key and check the response to see, if the keyserver if working.
This check doesn't test, if the keyserver has any keys. It only tests if the keyserver is answering correctly.
[#171 state:fixed]
  • Loading branch information...
Mento committed Jan 7, 2019
1 parent 9885260 commit 80c68f38471dc083060deb84ef8e8e36753d3113
Showing with 5 additions and 2 deletions.
  1. +5 −2 Source/GPGController.m
@@ -2356,7 +2356,7 @@ - (void)testKeyserver {
gpgTask.batchMode = YES;
gpgTask.nonBlocking = YES;
[gpgTask addArgument:@"--search-keys"];
[gpgTask addArgument:@"0x0000000000000000"];
[gpgTask addArgument:@"0x0000000000000000000000000000000000000000"]; // Search for a non-existing key.


dispatch_group_t dispatchGroup = dispatch_group_create();
@@ -2365,7 +2365,10 @@ - (void)testKeyserver {
});
// Wait a maximum of 30 seconds for the answer. 10 seconds more than the keyserver timeout, to give some setup time.
if (dispatch_group_wait(dispatchGroup, dispatch_time(DISPATCH_TIME_NOW, 30 * NSEC_PER_SEC)) == 0) {
if (gpgTask.errorCode == GPGErrorNoError || gpgTask.errorCode == GPGErrorCancelled || gpgTask.errorCode == GPGErrorNoData) {
if (gpgTask.errorCode == GPGErrorNoError || // Everything is good. Very unlikely, but ok.
gpgTask.errorCode == GPGErrorCancelled || // Test was cancelled. No need to show a warning.
gpgTask.errorCode == GPGErrorNoData || // Normal (key not found) response from old (< 2.2.12) gpg.
gpgTask.errorCode == GPGErrorNotFound) { // Normal (key not found) response from new (>= 2.2.12) gpg.
result = YES;
}
} else {

0 comments on commit 80c68f3

Please sign in to comment.