@@ -135,10 +135,7 @@ def __sign_file__(self, fname, url, key):
135
135
with urlopen (url ) as response :
136
136
h .update (response .read ())
137
137
signer = eddsa .new (key , 'rfc8032' )
138
- return (
139
- url ,
140
- base64 .b64encode (signer .sign (h )).decode ()
141
- )
138
+ return base64 .b64encode (signer .sign (h )).decode ()
142
139
143
140
def __encrypt_key__ (self , key , password , iterations ):
144
141
""" Encrypts key with PBKDF2 and AES-256. """
@@ -833,21 +830,21 @@ def on_post_build(self, config, **kwargs):
833
830
)
834
831
835
832
if self .config ['sign_files' ]:
836
- signatures = []
833
+ signatures = {}
834
+ urls_to_verify = []
837
835
for file in self .setup ['files_to_sign' ]:
838
- signatures .append (
839
- self .__sign_file__ (file ['file' ], file ['url' ], self .setup ['sign_key' ])
840
- )
836
+ signatures [file ['url' ]] = self .__sign_file__ (file ['file' ], file ['url' ], self .setup ['sign_key' ])
837
+ urls_to_verify .append (file ['url' ])
841
838
if signatures :
842
839
sign_file_path = Path (config .data ["site_dir" ] + '/' + self .config ['sign_files' ])
843
840
with open (sign_file_path , "w" ) as file :
844
841
file .write (json .dumps (signatures ))
845
842
846
843
canary_file = self .setup ['config_path' ].joinpath ('canary.py' )
847
- if not exists ( canary_file ):
848
- canary_py = Template ( self .setup ['canary_template' ]). render ({
849
- 'public_key ' : self . setup [ 'sign_key' ]. public_key (). export_key ( format = 'PEM' ) ,
850
- 'signature_url' : config . data [ "site_url" ] + self . config [ 'sign_files' ]
851
- })
852
- with open (canary_file , 'w' ) as file :
853
- file .write (canary_py )
844
+ canary_py = Template ( self . setup [ 'canary_template' ]). render ({
845
+ 'public_key' : self .setup ['sign_key' ]. public_key (). export_key ( format = 'PEM' ),
846
+ 'signature_url ' : config . data [ "site_url" ] + self . config [ 'sign_files' ] ,
847
+ 'urls_to_verify' : json . dumps ( urls_to_verify ),
848
+ })
849
+ with open (canary_file , 'w' ) as file :
850
+ file .write (canary_py )
0 commit comments