diff --git a/httpsig.py b/httpsig.py index 7495ab1b0..8987f0f23 100644 --- a/httpsig.py +++ b/httpsig.py @@ -191,11 +191,17 @@ def verifyPostHeaders(httpPrefix: str,publicKeyPem: str,headers: dict, \ #print('***************************Verify digest: SHA-256='+bodyDigest) #print('***************************Verify messageBodyJsonStr: '+messageBodyJsonStr) elif signedHeader == 'content-length' or signedHeader == 'Content-Length': - if int(headers[signedHeader])!=contentLength: + if headers.get(signedHeader): + if int(headers[signedHeader])!=contentLength: + if debug: + print('DEBUG: verifyPostHeaders content-length does not match '+headers[signedHeader]+' != '+str(contentLength)) + return False if debug: - print('DEBUG: verifyPostHeaders content-length does not match '+headers[signedHeader]+' != '+str(contentLength)) - return False - signedHeaderList.append(f'content-length: {headers[signedHeader]}') + print('DEBUG: verifyPostHeaders adding content-length to signedHeaderList') + signedHeaderList.append(f'content-length: {headers[signedHeader]}') + else: + if debug: + print('DEBUG: verifyPostHeaders '+signedHeader+' not found in '+str(headers)) else: if headers.get(signedHeader): if signedHeader=='date':