Add query parameter to WKD URLs

This change adds the l=LOCAL-PART query parameter to WKD URLs as
specified in RFC Draft: draft-koch-openpgp-webkey-service-09 section 3.1
since version 07.
This commit is contained in:
Eero Häkkinen
2020-02-17 00:11:24 +02:00
parent 2f0c1415b4
commit e901322ea3
2 changed files with 34 additions and 4 deletions

View File

@@ -2,8 +2,10 @@ package org.sufficientlysecure.keychain.util;
import android.support.annotation.Nullable;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.regex.Matcher;
@@ -50,13 +52,15 @@ public class WebKeyDirectoryUtil {
if(wkdMethodAdvanced) {
// Advanced method
return new URL("https://openpgpkey." + domain + "/.well-known/openpgpkey/" + domain + "/hu/" + encodedPart);
return new URL("https://openpgpkey." + domain + "/.well-known/openpgpkey/" + domain + "/hu/" + encodedPart + "?l=" + URLEncoder.encode(localPart, "UTF-8"));
}else{
// Direct method
return new URL("https://" + domain + "/.well-known/openpgpkey/hu/" + encodedPart);
return new URL("https://" + domain + "/.well-known/openpgpkey/hu/" + encodedPart + "?l=" + URLEncoder.encode(localPart, "UTF-8"));
}
} catch (MalformedURLException e) {
return null;
} catch (UnsupportedEncodingException e) {
return null;
}
}