Hi! I took a stab at this in my bug17639branch. I'm not totally sold on that command line flag or the implementation, so if someone can think of something more user friendly or intuitive, I'd be happy to hear better ideas!
This looks comparatively solid to me! A few things to consider as possibilities, though maybe they're not needed:
Maybe this should printf() something to stdout, instead of using the log facility, and run at --quiet by default?
Yes, this makes sense. TBH, I didn't know if I was allowed/encouraged to do printf(), since it seems like there's a lot of ways "interfaces" over stdin/stdout can be bad/broken/wrong, particularly when they are relied upon by other scripts/programs (cf. gnupg). I think it does make sense though to work even with --quiet, and in this case the user is asking a question like "hey parse this thing and tell me what it says", not intending any operation or for the binary to run as a daemon or anything more complicated, so it makes sense here.
Maybe the output format should be machine-readable?
Yeah! But what should this look like?
Literally just spit out the expiry in ISO8601 format? (With or without the underscore in between the date and the time?) Or some more easily machine parseable (but less human readable) format, like seconds-since-epoch?
Should it be in the local timezone, or in UTC? (Probably UTC, right? if we expect scripts to be able to process it?)
Maybe it should dump information about the installed authority auth key as well
I wonder what it should do about hidden service keys?
Yes, I can add these. I thought about the first one before, but I didn't know how to make the interface, plus had worries about the patch being large/invasive. I think the "proper" way to do it would be to add a suboptions parser so that the user could be like "--key-expiration auth" or "--key-expiration sign"; this way, it would more easily extendable to further changes in supported cert types moving forward.
I'm not sure what to do about onion service keys/certs at all. I imagine there are users with multiple hidden services. Frankly, I didn't even know OS keys/certs could expire. Is that just a v2 thing? Is there some canonical way to refer to an onion service such that I could provide some option like "--key-expiration specifier-for-my-onion-service"? Should I optionally take an onion service's address and learn the keys from the configured onion service directory?
Technically speaking, keys don't expire: certificates do. The user needs to replace both of them, not just one.
Right. How should we communicate this to users? I'm not a UX person at all, but I can vaguely naïvely foresee confusion of like "but I was asking about my keys". Should I change to the cmdline flag to --cert-expiration?
The buffer in log_ed_key_expiration() can probably just be stack-allocated.
Yep, done in cc2af48569.
Documentation on the new option should go into the manpage
Yeah… it would probably be the nice thing to do to tell operators how to use it. :) I will add this once we agree on what the commandline flags and output should be like.
I vote for something like
{{{
signing-cert-expiry: 2017-07-25 08:30:15 UTC
}}}
for the output format, and document that you need to grep for the signing-cert-expiry.
I guess that's probably enough, plus the manpage. What do you think?
Sounds good! This fits in well with the char *description for certs, so we should be able to expand this output format easily in the future for other/new types of certs.
This looks comparatively solid to me! A few things to consider as possibilities, though maybe they're not needed:
Maybe this should printf() something to stdout, instead of using the log facility, and run at --quiet by default?
Yes, this makes sense. TBH, I didn't know if I was allowed/encouraged to do printf(), since it seems like there's a lot of ways "interfaces" over stdin/stdout can be bad/broken/wrong, particularly when they are relied upon by other scripts/programs (cf. gnupg). I think it does make sense though to work even with --quiet, and in this case the user is asking a question like "hey parse this thing and tell me what it says", not intending any operation or for the binary to run as a daemon or anything more complicated, so it makes sense here.
Maybe the output format should be machine-readable?
Yeah! But what should this look like?
Literally just spit out the expiry in ISO8601 format? (With or without the underscore in between the date and the time?) Or some more easily machine parseable (but less human readable) format, like seconds-since-epoch?
Should it be in the local timezone, or in UTC? (Probably UTC, right? if we expect scripts to be able to process it?)
Maybe it should dump information about the installed authority auth key as well
I wonder what it should do about hidden service keys?
Yes, I can add these. I thought about the first one before, but I didn't know how to make the interface, plus had worries about the patch being large/invasive. I think the "proper" way to do it would be to add a suboptions parser so that the user could be like "--key-expiration auth" or "--key-expiration sign"; this way, it would more easily extendable to further changes in supported cert types moving forward.
This is done in commit7c2329c3eb, or the suboptions parsing is, at least. I didn't add parsers for auth keys or onion service keys yet, because I don't really understand which key is the auth key ("dir-identity-key"?) and the following questions about OS keys:
I'm not sure what to do about onion service keys/certs at all. I imagine there are users with multiple hidden services. Frankly, I didn't even know OS keys/certs could expire. Is that just a v2 thing? Is there some canonical way to refer to an onion service such that I could provide some option like "--key-expiration specifier-for-my-onion-service"? Should I optionally take an onion service's address and learn the keys from the configured onion service directory?
Technically speaking, keys don't expire: certificates do. The user needs to replace both of them, not just one.
Right. How should we communicate this to users? I'm not a UX person at all, but I can vaguely naïvely foresee confusion of like "but I was asking about my keys". Should I change to the cmdline flag to --cert-expiration?
For this, I kept the command line flag as "--key-expiration" but all the function/object names and documentation in the code uses "key certificate" or just "certificate" everywhere. (Commitd01793e2ee.)
The buffer in log_ed_key_expiration() can probably just be stack-allocated.
Yep, done in cc2af48569.
Documentation on the new option should go into the manpage
Yeah… it would probably be the nice thing to do to tell operators how to use it. :) I will add this once we agree on what the commandline flags and output should be like.
I tried this out, but when I ran make check, the new test failed. Otherwise it looks okay to me.
Oops, there was one line of code sitting in my tree that didn't get committed. It's added in commit 9b3b63c3d and should fix the test (by printing to stderr rather than stdout).