Skip to content

Commit b85d6eb

Browse files
committed
Made the example fit the 72 chars per line
1 parent a771174 commit b85d6eb

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

IETF-RFC.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -939,9 +939,11 @@ Here is an example of headers needed to sign a request.
939939
"@request-target": "post /path",
940940
"content-length": 380,
941941
"date": "Mon, 08 Jul 2024 14:16:20 GMT",
942-
"content-digest": "SHA-256=U7gNVUQiixe5BRbp4Tg0xCZMTcSWXXUZI2\\/xtHM40S0=",
942+
"content-digest": "SHA-256=U7gNVUQiixe5BRbp4...",
943943
"host": "hostname.of.the.recipient",
944-
"Signature": "keyId=\"https://author.hostname/key\",algorithm=\"rsa-sha256\",headers=\"content-length date digest host\",signature=\"DzN12OCS1rsA[...]o0VmxjQooRo6HHabg==\""
944+
"Signature": "keyId=\"https://author.hostname/key\",algorithm=
945+
\"rsa-sha256\",headers=\"content-length date digest host\",
946+
signature=\"DzN12OCS1rsA[...]o0VmxjQooRo6HHabg==\""
945947
}
946948
~~~~~
947949

@@ -978,15 +980,18 @@ outgoing requests:
978980

979981
~~~~~
980982
headers = {
981-
'content-length': length_of(payload),
982-
'date': current_gmt_datetime(), # Use a function to get the current GMT date as 'D, d M Y H:i:s T'
983-
'content-digest': 'SHA-256=' + base64_encode(hash('sha256', utf8_encode(payload))),
984-
'host': 'recipient-fqdn',
983+
'content-length': length_of(payload),
984+
# Use a function to get the current GMT date as 'D, d M Y H:i:s T'
985+
'date': current_gmt_datetime(),
986+
'content-digest': 'SHA-256=' + base64_encode(hash('sha256',
987+
utf8_encode(payload))),
988+
'host': 'recipient-fqdn',
985989
}
986990

987-
signed = ssl_sign(concatenate_with_newlines(headers), private_key, 'sha256')
991+
signed = ssl_sign(concatenate_with_newlines(headers),
992+
private_key, 'sha256')
988993
signature = {
989-
'keyId': 'sender-fqdn', # The sending server's FQDN; find its public key through OCM API discovery
994+
'keyId': 'sender.fqdn', # The sending server's FQDN
990995
'algorithm': 'rsa-sha256',
991996
'headers': 'content-length date content-digest host',
992997
'signature': signed,
@@ -1020,13 +1025,15 @@ the signature and the public key:
10201025
~~~~~
10211026
clear = {
10221027
'content-length': length_of(payload),
1023-
'date': 'Mon, 08 Jul 2024 14:16:20 GMT', # The date used in the verification process
1024-
'content-digest': 'SHA-256=' + base64_encode(hash('sha256', utf8_encode(payload))), # Recompute the digest for verification
1028+
'date': 'Mon, 08 Jul 2024 14:16:20 GMT',
1029+
'content-digest': 'SHA-256=' + base64_encode(hash('sha256',
1030+
utf8_encode(payload))), # Recompute digest for verification
10251031
'host': 'sender-fqdn',
10261032
}
10271033

10281034
signed = headers['Signature']
1029-
verification_result = ssl_verify(concatenate_with_newlines(clear), signed, public_key, 'sha256')
1035+
verification_result = ssl_verify(concatenate_with_newlines(clear),
1036+
signed, public_key, 'sha256')
10301037

10311038
if not verification_result then
10321039
raise InvalidSignatureException

0 commit comments

Comments
 (0)