Use uppercase hex digits in database and API.

- Both Sequoia and GnuPG create query strings with uppercase hex
    digits.  By using uppercase in the filesystem and new API, we can
    serve keys using nginx.
This commit is contained in:
Justus Winter 2019-02-22 22:13:38 +01:00
parent c428e6bb42
commit 13ea83b10d
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
3 changed files with 8 additions and 7 deletions

View File

@ -43,9 +43,10 @@ Hagrid has it's own URL scheme to fetch keys, verify user IDs and delete keys.
It's meant to be machine readable, but it's not a REST API. The following URLs
are handled.
- `GET /by-fingerprint/<fingerprint>` retrieves the key with the given
fingerprint.
- `GET /by-keyid/<key ID>` retrieves the key with the given long key ID.
- `GET /by-fingerprint/<FINGERPRINT>` retrieves the key with the given
fingerprint. Hexadecimal digits must be uppercase.
- `GET /by-keyid/<KEY-ID>` retrieves the key with the given long key
ID. Hexadecimal digits must be uppercase.
- `GET /by-email/<URL-encoded user ID>` retrieves the key with the given user
ID. Only exact matches are accepted.
- `GET /vks/verify/<token>` verifies a user ID using a token string send by

View File

@ -160,14 +160,14 @@ impl Filesystem {
/// Returns the path to the given KeyID.
fn path_to_keyid(&self, keyid: &openpgp::KeyID) -> PathBuf {
let hex = keyid.to_hex().to_lowercase();
let hex = keyid.to_hex();
self.base_by_keyid.join(&hex[..2]).join(&hex[2..])
}
/// Returns the path to the given Fingerprint.
fn path_to_fingerprint(&self, fingerprint: &openpgp::Fingerprint)
-> PathBuf {
let hex = fingerprint.to_hex().to_lowercase();
let hex = fingerprint.to_hex();
self.base_by_fingerprint.join(&hex[..2]).join(&hex[2..])
}

View File

@ -56,7 +56,7 @@ impl TryFrom<sequoia_openpgp::Fingerprint> for Fingerprint {
impl ToString for Fingerprint {
fn to_string(&self) -> String {
hex::encode(&self.0[..])
hex::encode_upper(&self.0[..])
}
}
@ -133,7 +133,7 @@ impl From<Fingerprint> for KeyID {
impl ToString for KeyID {
fn to_string(&self) -> String {
hex::encode(&self.0[..])
hex::encode_upper(&self.0[..])
}
}