wip
This commit is contained in:
parent
005c640b1f
commit
7ffde9de18
3 changed files with 84 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
from os.path import join, exists
|
||||||
|
from cryptography.hazmat.primitives import serialization as crypto_serialization
|
||||||
|
from cryptography.hazmat.primitives.asymmetric import rsa
|
||||||
|
from cryptography.hazmat.backends import default_backend as crypto_default_backend
|
||||||
|
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
'apt': {
|
'apt': {
|
||||||
'packages': {
|
'packages': {
|
||||||
|
@ -7,5 +13,54 @@ defaults = {
|
||||||
},
|
},
|
||||||
'opendkim': {
|
'opendkim': {
|
||||||
'domains': [],
|
'domains': [],
|
||||||
|
'keys': {},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@metadata_reactor.provides(
|
||||||
|
'opendkim/keys'
|
||||||
|
)
|
||||||
|
def keys(metadata):
|
||||||
|
keys = {}
|
||||||
|
|
||||||
|
for domain in metadata.get('opendkim/domains'):
|
||||||
|
if domain in metadata.get(f'opendkim/keys'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
pubkey_path = join(repo.path, 'data', 'dkim', f'{domain}.privkey')
|
||||||
|
privkey_path = join(repo.path, 'data', 'dkim', f'{domain}.pubkey')
|
||||||
|
|
||||||
|
if not exists(pubkey_path) or not exists(privkey_path):
|
||||||
|
key = rsa.generate_private_key(
|
||||||
|
backend=crypto_default_backend(),
|
||||||
|
public_exponent=65537,
|
||||||
|
key_size=2048
|
||||||
|
)
|
||||||
|
with open(pubkey_path, 'w') as file:
|
||||||
|
file.write(
|
||||||
|
key.public_key().public_bytes(
|
||||||
|
crypto_serialization.Encoding.OpenSSH,
|
||||||
|
crypto_serialization.PublicFormat.OpenSSH
|
||||||
|
).decode()
|
||||||
|
)
|
||||||
|
with open(privkey_path, 'w') as file:
|
||||||
|
file.write(
|
||||||
|
key.private_bytes(
|
||||||
|
crypto_serialization.Encoding.PEM,
|
||||||
|
crypto_serialization.PrivateFormat.PKCS8,
|
||||||
|
crypto_serialization.NoEncryption()
|
||||||
|
).decode()
|
||||||
|
)
|
||||||
|
|
||||||
|
with open(pubkey_path, 'r') as pubkey:
|
||||||
|
with open(privkey_path, 'r') as privkey:
|
||||||
|
keys[domain] = {
|
||||||
|
'public': pubkey.read(),
|
||||||
|
'private': privkey.read(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
'opendkim': {
|
||||||
|
'keys': keys,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
1
data/dkim/mail2.sublimity.de.privkey
Normal file
1
data/dkim/mail2.sublimity.de.privkey
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1DDDUIj7qX9NovO8SbuzaL+cc4JInAVb2DXTHEZh7o9guW/n2drpLEUA6fS6d8yBWXvbijyp4X3+9qP0R2j64QMNFaK3crnXo0Og8ko2in2Tz9NeICN8wJtzLw8lTifCxarwPxHWbKsJLkZlZJS78+BSn4dDSjedNjnH/ah9ST0fVL/yi6NmQ8be5jZK1pXVgaED6RcjkdgXUI2DkfV5yM9lSx3LjhPj6iJWQ0ixMpKJEnBMfrOlcKDPmfJBiNkUyx4MJOBMhzy50oBPacYXVZoC1FsACT2TVkUQ52USW4jyxBozyyR3rIYeaGQkU33DYOgSQ6gF3sozW7HnIriHj
|
28
data/dkim/mail2.sublimity.de.pubkey
Normal file
28
data/dkim/mail2.sublimity.de.pubkey
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC1DDDUIj7qX9No
|
||||||
|
vO8SbuzaL+cc4JInAVb2DXTHEZh7o9guW/n2drpLEUA6fS6d8yBWXvbijyp4X3+9
|
||||||
|
qP0R2j64QMNFaK3crnXo0Og8ko2in2Tz9NeICN8wJtzLw8lTifCxarwPxHWbKsJL
|
||||||
|
k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IBDA0bAgYZ
|
||||||
|
RuASdBB8pJe2grmVtNFNWfwP9MOGG4kMoExReatUekr04ut5xiNzmMWyLor77/4u
|
||||||
|
NEd9eI/6oJjkK+0svvrAcbSacl9bbpjetUNOYjYqKTXIzockRguQsSU4UQKBgQCA
|
||||||
|
KkIQtFiOTQ8FMmPRoaqM9bgY5V6jliQBJQi6N7Qf0/EPImtq43aCZ51WWj1sZMhO
|
||||||
|
X9ycQ4ax/rp5kQM9l6GMb6Wo8DaN1YeWf6s9Gf2B8npbhBnDMjm8d5Jv93eOo0YQ
|
||||||
|
S1Uuw3dbvfSQstFKBhOOplZOl1RGAooblCRljCxUgQKBgBItURsxoH8tgnVHsYu5
|
||||||
|
gdnJHo3CEd0pnX2a4wn5/Rnh5vm6j7zLEpwuEGUq2OBC8ccCiSeNZIJnKI6oXnv0
|
||||||
|
tdLuDvaaO3E13VcA/EBS6bgdHtC9tR1OWPLxrlTP6lPywLqBoIcrSuAun/hJNE+G
|
||||||
|
5b/xXoOLw9KNkcbqXBHOhiwg
|
||||||
|
-----END PRIVATE KEY-----
|
Loading…
Reference in a new issue