<div dir="ltr"><div><div>$ openssl rand -base64 48 | awk '{print "-----BEGIN SESSION TICKET KEY-----"; print; print "-----END SESSION TICKET KEY-----"}' >> ticket.key.new && cat ticket.key | awk 'sa==1{n++;sa=1}/-----BEGIN SESSION TICKET KEY-----/{sa=1;X=2}{if(n<3*X){print;}}' >> ticket.key.new && mv ticket.key.new ticket.key<br>
<br></div>store not more than X=2 old keys + new one, you can add it to cron file.<br><br>I know it's weird to use awk, but I only try to illustrate that it's not a big problem to rotate keys with my schema ;) But you can' rotate keys with oneliner if you use "one key per file schema" - there'll be too big probability of mistake during nginx config parsing.<br>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Sep 30, 2013 at 7:31 PM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<div class="im"><br>
On Mon, Sep 30, 2013 at 07:14:59PM +0400, kyprizel wrote:<br>
<br>
> $ openssl rand -base64 48 | awk '{print "-----BEGIN SESSION TICKET<br>
> KEY-----"; print; print "-----END SESSION TICKET KEY-----"}' >><br>
> ticket.key.new && cat ticket.key >> ticket.key.new && mv ticket.key.new<br>
> ticket.key<br>
><br>
> There is no difference b/w binary and PEM form here, but I prefer to see<br>
> config files in printable characters.<br>
<br>
</div>I would prefer printable configs as well.  But I don't really<br>
think that adding PEM header/footer with awk counts as a trivial<br>
way to do things.  It's not something an ordinary admin can do<br>
with at least 50% chance of getting a correct result for the first<br>
time.<br>
<br>
And, BTW, your key rotation lacks removing of an old key, which<br>
makes it unusable.  Correct implementation will require keeping<br>
each key in it's own file - which essentially makes "single file<br>
per key" aproach more natural.<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Maxim Dounin<br>
<a href="http://nginx.org/en/donation.html" target="_blank">http://nginx.org/en/donation.html</a><br>
<br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</div></div></blockquote></div><br></div>