-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web key directory #121
Comments
i just stumbled across this question, too. |
There is a python script to generate .well-known/openpgpkey/hu/ from a keyring - https://hg.intevation.de/gnupg/wkd-tools/file/tip/generate-openpgpkey-hu, but we should probably use the existing database and map the wkd requests to hkps search requests. |
The format that WKD expects, It might be possible to do this url rewriting in web server as well. decode the request to email address and then rewrite the url to search by email address with an option to return raw data (probably in binary since wkd expects binary data - at least the example url returned binary data). |
if we can get the hash generation logic figured out, then it can be simple I think.
Update: we can already pass options=mr https://keys.puri.sm/pks/lookup?op=get&[email protected]&options=mr |
https://gist.github.com/kafene/0a6e259996862d35845784e6e5dbfc79 this is a useful resource. It shows how to generate the wkd-hash with gpg command itself. We need to find a way to do the same in Javascript. |
https://github.com/openpgpjs/wkd-client/blob/master/src/wkd.js#L50 this has js code for generating the hash. |
Based on wkd-client code, I was able to generate this hash using this code snippet.
|
I manged to get the hash generated, but unable to pass the value back from util.js to public-key.js. Need to figure out doing this with proper async/await.
|
In the above, What needs to be done is to return the promise of crypto.subtle.digest itself, like this:
And then when you call it, you've to wait for the promise to resolve, like this:
This hashing operation seems to be destructive in that we cannot get the email address back from the hash. Therefore your latter comment about having to store the hash in the database seems right. Meaning for existing keys, there'll have to be a separate function to calculate the hashes and save to DB. And for new keys being uploaded, the hash can be calculated along with fingerprint, etc. You could add a wkd endpoint like the hkp endpoint:
But of course, implementing the lookup requires the hash to be saved. |
@asdofindia thanks, let me try this. Thanks also to Ananthu CV who also helped making this a promise.
|
@asdofindia I tried adding src/route/wkd.js and visiting the .well-known/openpgpkey/hu/g4rf118d16sbj3k77d5txywpm879pszg which resulted in a 404. I think we should try to get a key not found/another debug message printed to get started before implementing the lookup part. |
With the following code,
I'm able to get the raw ascii armored key when looking for /pks/lookup?op=get&search=g4rf118d16sbj3k77d5txywpm879pszg%40puri.sm&options=wkd Now we just need to either add a wkd route or a url rewriting scheme in web server that will redirect to this url from the wkd direct url. |
So we have two options to do this mapping,
Domain name will need to dynamically selected based on the request url since the local part of hash is not unique. |
with this in CaddyFile, I can get the key from https://openpgpkey.puri.sm/.well-known/openpgpkey/puri.sm/hu/g4rf118d16sbj3k77d5txywpm879pszg (this is a restricted url for now). |
Though
|
Added
to CaddyFile and I wonder if gpg is expecting a binary file instead of ascii armored data. I read somewhere gpg can accept ascii armored data as well now. |
The request finally timed out with this error, though the url is accessible via browser (behind a vpn). https://gist.github.com/kafene/0a6e259996862d35845784e6e5dbfc79 has some hints about mime types. |
I wonder if the following line in src/route/hkp.js is the problem
|
With gpg 2.4.5, the error is now changed
|
I think we will need to convert the ascii armored key to binary when options is wkd. |
I could not find a way to dearmor with openpgp.js so I used gpg command to dearmor
But even then gpg fails to get the key,
|
Hmm... I'd advise to use the Web Key Directory checker but I just sunsetted it last month! 😬 GnuPG may cache the result and return error even if you fixed everything. I'd suggest creating the WKD URL manually and visiting it with I can do more thorough checks but only on Monday. |
I have removed the firewall to allow access to everyone and this is the curl output.
|
|
Earlier it was waiting for terminal input before overwriting the .gpg file, I changed it to check for the file before running gpg --dearmor but still no luck with gpg client.
|
Using https://sequoia-pgp.org/tools/wkd/ This gave,
Update: this is probably broken since the same error is shown for [email protected] which has a working WKD implementation. |
Well, Sequoia's WKD checker really uses mine and since I shut down mine it's not working 🤷♂️ |
❯ gpg-wks-client --print-wkd-url [email protected]
https://openpgpkey.puri.sm/.well-known/openpgpkey/puri.sm/hu/g4rf118d16sbj3k77d5txywpm879pszg?l=praveen It seems like Anyhow, gpg seems to be looking there which in this case returns Not found. |
@asdofindia yay! That was the really missing secret sauce! After adding
|
All the WKD documentation/wiki pages and tutorials will need to be updated. |
#146 is ready for review (I don't have a lot of experience with coding, so I'm sure there can be many improvements). |
I'm trying to see if we can do this entirely in caddy/web server without generating and storing the wkd hash since we now know the localPart is passed as a query parameter which can be used to search by email address. I'm trying this,
But {query} is "l=praveen" so we need a way to strip out "l=" also from that. I tried |
With just a small change, I can get the keys without storing the wkd hash.
|
#147 submitted as a simpler method for wkd support. |
Can this expose the public keys according to GPG Web Key Directory?
It would also be helpful to guide on what DNS records need to be set and other such setups in order to get the keyserver to be auto-detected, and which clients/gpg versions support which setup.
The text was updated successfully, but these errors were encountered: