Minor cleanup for ARC
This commit is contained in:
+19
-3
@@ -37,9 +37,14 @@ import hashlib
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# only needed for arc
|
||||||
|
try:
|
||||||
|
from authres import AuthenticationResultsHeader
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
from authres import *
|
|
||||||
from authres.arc import *
|
|
||||||
|
|
||||||
from dkim.canonicalization import (
|
from dkim.canonicalization import (
|
||||||
CanonicalizationPolicy,
|
CanonicalizationPolicy,
|
||||||
@@ -144,6 +149,10 @@ class ValidationError(DKIMException):
|
|||||||
"""Validation error."""
|
"""Validation error."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class AuthresNotFoundError(DKIMException):
|
||||||
|
""" Authres Package not installed, needed for ARC """
|
||||||
|
pass
|
||||||
|
|
||||||
def select_headers(headers, include_headers):
|
def select_headers(headers, include_headers):
|
||||||
"""Select message header fields to be signed/verified.
|
"""Select message header fields to be signed/verified.
|
||||||
|
|
||||||
@@ -499,7 +508,6 @@ class DomainSigner(object):
|
|||||||
sig = dict(fields)
|
sig = dict(fields)
|
||||||
|
|
||||||
headers = canon_policy.canonicalize_headers(self.headers)
|
headers = canon_policy.canonicalize_headers(self.headers)
|
||||||
|
|
||||||
self.signed_headers = hash_headers(
|
self.signed_headers = hash_headers(
|
||||||
h, canon_policy, headers, include_headers, header, sig)
|
h, canon_policy, headers, include_headers, header, sig)
|
||||||
self.logger.debug("sign %s headers: %r" % (header_name, h.hashed()))
|
self.logger.debug("sign %s headers: %r" % (header_name, h.hashed()))
|
||||||
@@ -777,6 +785,14 @@ class ARC(DomainSigner):
|
|||||||
#: formed.
|
#: formed.
|
||||||
def sign(self, selector, domain, privkey, srv_id, include_headers=None,
|
def sign(self, selector, domain, privkey, srv_id, include_headers=None,
|
||||||
timestamp=None, standardize=False):
|
timestamp=None, standardize=False):
|
||||||
|
|
||||||
|
# check if authres has been imported
|
||||||
|
try:
|
||||||
|
AuthenticationResultsHeader
|
||||||
|
except:
|
||||||
|
self.logger.debug("authres package not installed")
|
||||||
|
raise AuthresNotFoundError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pk = parse_pem_private_key(privkey)
|
pk = parse_pem_private_key(privkey)
|
||||||
except UnparsableKeyError as e:
|
except UnparsableKeyError as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user