+
+ if (host[0] == 0) {
+ logthing(LOGTHING_CRITICAL, "Couldn't parse HKP host: %s",
+ url);
+ ret = 0;
+ goto out;
+ }
+
+ if (proto[0] == 0 || !strcmp(proto, "hkp")) {
+ if (port == 0) {
+ port = 11371;
+ }
+ snprintf(hkpbase, sizeof(hkpbase),
+ "http://%s:%u/pks", host, port);
+ } else if (!strcmp(proto, "hkps")) {
+ if (port == 0) {
+ port = 11372;
+ }
+ snprintf(hkpbase, sizeof(hkpbase),
+ "https://%s:%u/pks", host, port);
+ } else if (strcmp(proto, "http") && strcmp(proto, "https")) {
+ logthing(LOGTHING_CRITICAL, "Unknown HKP protocol: %s",
+ proto);
+ ret = 0;
+ goto out;
+ } else if (port == 0) {
+ snprintf(hkpbase, sizeof(hkpbase),
+ "%s://%s/pks", proto, host);
+ } else {
+ snprintf(hkpbase, sizeof(hkpbase),
+ "%s://%s:%u/pks", proto, host, port);
+ }
+
+out:
+ return ret;