|
# Generate new keypair |
|
pubKey = subprocess.run(("rspamadm", "dkim_keygen", |
|
"-s", selector, |
|
"-b", "2048", |
|
"-d", domain, |
|
"-t", type, |
|
"-k", privateKeyFilepath), |
|
stdout=subprocess.PIPE, |
|
universal_newlines=True).stdout |
|
subprocess.run(("chown", "grommunio:grommunio", privateKeyFilepath)) |
|
subprocess.run(("chmod", "440", privateKeyFilepath)) |
|
return pubKey, None |
I think the generated DNS-Record should also be stored in e.g. /var/lib/grommunio-admin-api/$DOMAIN.$SELECTOR.txt to have it available at a later time.
It seems to me that even if you generate a key and follow the instructions the admin-web/ doesn't care about the just generated files. Should those files be detected and also displayed (including the DNS-Record :P) and compared to the values the DNSCheck retrieves to not do the whole thing over and over if you for instance can't set it at this time and the TTL takes forever and whatnot? 🙈
And maybe (but just maybe) it would be good to also add a <select> for the output modes -o [dns|dnskey|plain].
In general the stored record with the option -o dnskey is IMHO the best format as it will not have any chars one would need to get rid off.
Because wrapping a too long entry (i'm looking at you bind9) can be easily taken care of with something like this:
cat $DOMAIN.$SELECT.txt | sed 's/.*v=DKIM/v=DKIM/' | fold -s -w76 | sed 's/^/"/g ; s/$/"/g ; 1s/^/(/ ; $s/$/)/' (the first sed is just for lines with leading 'dkim._domainkey IN TXT ...' and alike)
To illustrate the different output modes:
# rspamadm dkim_keygen -s dkim26 -b 2048 -d moep.com -k moep.com.dkim26.key -o dns
dkim26._domainkey IN TXT ( "v=DKIM1; k=rsa; "
"p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq/KngzxlM5zU4HJ4Gu0gg5HpSXWzZ1GE5Zh+oySO7/gKB1UmMKgqDnp9psHGF9oGHqGKIClSmLNiSlD+OarQNt0l52p3yqc7lUrToAwB89ayTQCrDquSeBSa1GLy/guNd1CmIbzd4TaCkrorLy9lEBjKSk1mC8Nun+D4JcBPTwOtdtV8bjjFbqHd9j/ZcHY7IDdY/DLkYtCJxUyn3"
"oJOpOtdYuruaFo3k0s90EeRKnieHLe/DSF9bplKhw9k4JtUXfFgY+yn4AJpFmwHsCEKCoELlKkCTzC2cElSriEWWKq/Bq49t7O55Ayq7hATURGss6C/qj58DwaR2spsdA71mQIDAQAB"
) ;
# rspamadm dkim_keygen -s dkim26 -b 2048 -d moep.com -k moep.com.dkim26.key -o dnskey
v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2LujRl5o3Lq7y/78eweCKeU8yUC3xSjXzZk4+ridy60yB3GN5bYeNMRZt7LFxB73djTFCvTGgJhDK5sXc2jmV1uGNW4LNQpCU6PA/m/vs9RYKgBBn76sbmV+mZdrdWsVTfSEX53aiRz85CnG+HKTKBPUDu3+2zIGaO68i7pKMJW4N32mrzgPKZxB3evIpTry0NdH5rUByzzvjd3DSQOIP3R97oQIpqpxi2LeiKX8pbr+ph9mOXzOGpgSSV7INQ6uLq0FupIYOozL4UqcsOaPD29px9EfPf+cgfvhyx/wezghYX048KpM+jHKDdOIjVpIvf14dQj03ecaSx+N9YsB4QIDAQAB
# rspamadm dkim_keygen -s dkim26 -b 2048 -d moep.com -k moep.com.dkim26.key -o plain
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA21MXZR+4mc2jVdvPJEnASo23ghVRQv26OF9hRHZ0JB9eKg2vOkEgqslMlQXH93UFAkumy99xgRqGB8kGP3k8luF34DFnEIHksX4CK7iDhJRwyRHCChjTIpuKPWBJ4pNK8OUvzuNp1W0YgA4tV0pehC9fow4qNoiqkdM7E6vlPFx4kW5lWh/bW4eh1ZjhXWe5/g+FWfZxmasXRbeBgmyKi/MiGCNmiWiym4Ux2RZxiAyYNBt6osqDySnYYeMPoJIipzeoBNtiL5oxcE9wYagFw3slUXg0CnMrLiVz0b2zbHZkIl7JdOgRFHUiWZ3ydINUl6XFykaHwc3mo7qIrFg4ywIDAQAB
wrap it short
# rspamadm dkim_keygen -s dkim26 -b 2048 -d moep.com -k moep.com.dkim26.key -o dnskey | sed 's/.*v=DKIM/v=DKIM/' | fold -s -w76 | sed 's/^/"/g ; s/$/"/g ; 1s/^/(/ ; $s/$/)/'
("v=DKIM1; k=rsa; "
"p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzAX6z4yZB6AbFM5aETebTEjjPYV93Q"
"Q1UaR6DfhNmMT21sVfIfOqMvJiY5NM/VhO+bqMc+IXhHRcuNTIt96VmeRXE7a1TBap4icucLSpuv"
"iX056nWUUIpnNVgJAO+zLcDpHnN7w3TgFIQXXoumQqSWlebg/V0LoDMmzNQ3E7uHFMI1YszzqCbi"
"8krRrWtr+zQ0FRtXzKDjikM/pQfmUTfnhaMkSxHYopm+IKgdm11BbeGXjilU2lbM+SFtvGZj+xEA"
"oRocYmqQYOO7L1vQWVqWfaeq7UKvLlS4Ko4y6UgrdsVoj2q0kb5tU8XxRH8QoEraBGbbrbHU2iBx"
"WGaF08IwIDAQAB")
admin-api/tools/dnsHealth.py
Lines 241 to 252 in 2b84604
I think the generated DNS-Record should also be stored in e.g.
/var/lib/grommunio-admin-api/$DOMAIN.$SELECTOR.txtto have it available at a later time.It seems to me that even if you generate a key and follow the instructions the admin-web/ doesn't care about the just generated files. Should those files be detected and also displayed (including the DNS-Record :P) and compared to the values the DNSCheck retrieves to not do the whole thing over and over if you for instance can't set it at this time and the TTL takes forever and whatnot? 🙈
And maybe (but just maybe) it would be good to also add a
<select>for the output modes-o [dns|dnskey|plain].In general the stored record with the option
-o dnskeyis IMHO the best format as it will not have any chars one would need to get rid off.Because wrapping a too long entry (i'm looking at you bind9) can be easily taken care of with something like this:
cat $DOMAIN.$SELECT.txt | sed 's/.*v=DKIM/v=DKIM/' | fold -s -w76 | sed 's/^/"/g ; s/$/"/g ; 1s/^/(/ ; $s/$/)/'(the first sed is just for lines with leading 'dkim._domainkey IN TXT ...' and alike)To illustrate the different output modes:
wrap it short