diff --git a/doc/ConfigToken.md b/doc/ConfigToken.md index 39a476b..3a7a94e 100644 --- a/doc/ConfigToken.md +++ b/doc/ConfigToken.md @@ -232,6 +232,29 @@ Mär 21 12:22:10 debian-grid-test systemd[1]: nvidia-gridd.service: Main process Mär 21 12:22:10 debian-grid-test systemd[1]: nvidia-gridd.service: Failed with result 'exit-code'. ``` +What is interesting, that `caChain` and `publicCert` on original dls response, contains 76 chars per line, +where our (default pem) only contains 64 chars. + +But even after splitting into 76 char-chunks + +``` +{"certificateConfiguration": {"caChain": ["-----BEGIN CERTIFICATE-----\r\nMIIF3TCCA8WgAwIBAgIUNoGIMFv9PE3CjR+dRdc0q5CqdAYwDQYJKoZIhvcNAQELBQAwcjELMAkG\r\nA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExDzANBgNVBAoMBk52aWRpYTEnMCUGA1UECwwe\r\nTnZpZGlhIExpY2Vuc2luZyBTZXJ2aWNlIChOTFMpMRQwEgYDVQQDDAtOTFMgUm9vdCBDQTAeFw0y\r\nNTAzMjAxMzIwMjZaFw0zNTAzMTkxMzIwMjZaMHoxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxp\r\nZm9ybmlhMQ8wDQYDVQQKDAZOdmlkaWExJzAlBgNVBAsMHk52aWRpYSBMaWNlbnNpbmcgU2Vydmlj\r\nZSAoTkxTKTEcMBoGA1UEAwwTTkxTIEludGVybWVkaWF0ZSBDQTCCAiIwDQYJKoZIhvcNAQEBBQAD\r\nggIPADCCAgoCggIBAKZ7bMxE1/PIL18Dnm31uaw9FjIVrCko1vcIOMpikaW77Oae/dFg/UiLV1yj\r\nGqrgwdQ+8odTG4+eGBeVA0nJJp++MtJWkxj0cnwu08/W2b411qCdAvhxqiYxHV3xt/LuoLqraCgH\r\nuy1vU0Pt2siFMJiLc37yMkjujDsht99Eb4gBVnvM90L6dBsQfqy4bnMC5ktOSf7QfQUTZRc8HzKw\r\n6FBfIat/WeazFemI4ZibDZE0a1NPyZIg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"mod": ["ac7bc9ad246cfe8252da0f3893f94ad509fa083277525c771a025d81b998461900de1301105764d886c39cc18bdf1c24b07d3adb15f7e6d213d0e405d3678a2a907535141771f4afc909b2aca5f89c66cf00148c8109fec08415fbb759e26ffaf48a6caa5f1b6bcffe62a7cfb90fab2cf6d42683f380d525fd7880897d306a82f73aafe9c38fcfdbb42b6db3ec0345f0b164baffd5b383c3172ffb0799eb5a78d5c381d4d413c08e7345f7bcb0196e9de16487935e23400197dcb9ccb7b698376000b57c740f66556130b77f5474b9e39aa9c11f53b630fe6c819504d89fc7e19653607b58cc8b4828b6170b392c0c075997e7220f667f853085ac3782b713a5"]}}, "configToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJOTFMgU2VydmljZSBJbnN0YW5jZSIsImF1ZCI6Ik5MUyBMaWNlbnNlZCBDbGllbnQiLCJpYXQiOjE3NDI1NjMyMjYsIm5iZiI6MTc0MjU2MzIyNiwiZXhwIjoyMTIxMjU0NDI2LCJwcm90b2NvbF92ZXJzaW9uIjoiMi4wIiwiZF9uYW1lIjoiRExTIiwic2VydmljZV9pbnN0YW5jZV9yZWYiOiI0ZTUzYTE3MS0xMDNiLTQ5NDYtOWVkOC01ZjRjMGVlNzUwZDkiLCJzZXJ2aWNlX2luc3RhbmNlX3B1YmxpY19rZXlfY29uZmlndXJhdGlvbiI6eyJzZXJ2aWNlX2luc3RhbmNlX3B1YmxpY19rZXlfbWUiOnsibW9kIjoiYWM3YmM5YWQyNDZjZmU4MjUyZGEwZjM4OTNmOTRhZDUwOWZhMDgzMjc3NTI1Yzc3MWEwMjVkODFiOTk4NDYxOTAwZGUxMzAxMTA1NzY0ZDg4NmMzOWNjMThiZGYxYzI0YjA3ZDNhZGIxNWY3ZTZkMjEzZDBlNDA1ZDM2NzhhMmE5MDc1MzUxNDE3NzFmNGFmYzkwOWIyYWNhNWY4OWM2NmNmMDAxNDhjODEwOWZlYzA4NDE1ZmJiNzU5ZTI2ZmZ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aZm5JZzltZjRVd2hhdzNncmNUXG5wUUlEQVFBQlxuLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tIiwia2V5X3JldGVudGlvbl9tb2RlIjoiTEFURVNUX09OTFkifX0.db4MVvs7kUt6i4ffEok2doqXGUE_9vicssjxwfGA71VyI9OEnvJ7lJ60E6h_ScNEEYwAs_Ghy4OyK_Wk-yt_vh80sbyn5Vd-CKY1A4UgFmG20k2mFKUOpr7hmkfhxkCURUnC0auYwi9OEsNDOi8L05HmQjYbdtOBUH1VlaGVP2oPeeLX7PFPcvARP-Jhm6WppZ321zYC-M39OovdFtJIgVTMA5cJtFvfeHVzCXoo5ybmjtXPbS4ZN_5M3ua8osMEQgIlxsJSdYcD9wDNIiWSPKJuXJKKWtpBzG09FuN4ew7pU-jQ6Rcd6NIS3l7Fv68ooQSjHi4Bu7UAn4YXdXx14Q"} +``` + +it results in the same error messages + +``` +Mär 21 14:21:43 debian-grid-test nvidia-gridd[503]: NLS initialized +Mär 21 14:21:43 debian-grid-test nvidia-gridd[503]: Failed to verify public certificate (error:0A000126:SSL routines::unexpected eof while reading) +Mär 21 14:21:43 debian-grid-test nvidia-gridd[503]: Failed to verify public certificate (error:00000000:lib(0)::reason(0)) +Mär 21 14:21:43 debian-grid-test nvidia-gridd[503]: Failed to validate public certificates +Mär 21 14:21:43 debian-grid-test nvidia-gridd[503]: Server configuration validation failed. Invalid certificate received from server. +Mär 21 14:21:43 debian-grid-test nvidia-gridd[503]: Failed to setup cloud License Manager: 3 +Mär 21 14:21:43 debian-grid-test nvidia-gridd[503]: Shutdown (503) +Mär 21 14:21:43 debian-grid-test systemd[1]: nvidia-gridd.service: Main process exited, code=exited, status=1/FAILURE +Mär 21 14:21:43 debian-grid-test systemd[1]: nvidia-gridd.service: Failed with result 'exit-code'. +``` + # Sources - https://8gwifi.org/PemParserFunctions.jsp \ No newline at end of file diff --git a/src/test/test_config_token.py b/src/test/test_config_token.py index 26bed89..c7ba1f8 100644 --- a/src/test/test_config_token.py +++ b/src/test/test_config_token.py @@ -1,7 +1,7 @@ import json from calendar import timegm from datetime import datetime, UTC, timedelta - +from textwrap import wrap from cryptography import x509 from cryptography.hazmat._oid import NameOID from cryptography.hazmat.primitives import serialization, hashes @@ -376,7 +376,7 @@ def test_our_config_token_with_our_key(): .add_extension(x509.SubjectAlternativeName([ x509.DNSName('4e53a171-103b-4946-9ed8-5f4c0ee750d9') ]), critical=False) - .sign(my_si_private_key, hashes.SHA256())) + .sign(my_ca_private_key, hashes.SHA256())) my_si_public_key_exp = my_si_certificate.public_key().public_numbers().e my_si_public_key_mod = f'{my_si_certificate.public_key().public_numbers().n:x}' # hex value without "0x" prefix @@ -403,6 +403,7 @@ def test_our_config_token_with_our_key(): "mod": hex(my_si_public_key.public_numbers().n)[2:], "exp": int(my_si_public_key.public_numbers().e), }, + # 64 chars per line (pem default) "service_instance_public_key_pem": my_si_public_key_as_pem.decode('utf-8').strip(), "key_retention_mode": "LATEST_ONLY" }, @@ -411,10 +412,29 @@ def test_our_config_token_with_our_key(): my_sign_key = jwk.construct(my_si_private_key_as_pem.decode('utf-8'), algorithm=ALGORITHMS.RS256) my_config_token = jws.sign(payload, key=my_sign_key, headers=None, algorithm=ALGORITHMS.RS256) + # generate a 76 char wide pem (does not work either, so this code can be removed) + response_ca_chain = my_ca_certificate.public_bytes(encoding=Encoding.PEM).decode('utf-8') + response_ca_chain = response_ca_chain.replace('-----BEGIN CERTIFICATE-----', '') + response_ca_chain = response_ca_chain.replace('-----END CERTIFICATE-----', '') + response_ca_chain = response_ca_chain.replace('\n', '') + response_ca_chain = wrap(response_ca_chain, 76) + response_ca_chain = '\r\n'.join(response_ca_chain) + response_ca_chain = f'-----BEGIN CERTIFICATE-----\r\n{response_ca_chain}\r\n-----END CERTIFICATE-----' + + response_si_certificate = my_si_certificate.public_bytes(encoding=Encoding.PEM).decode('utf-8') + response_si_certificate = response_si_certificate.replace('-----BEGIN CERTIFICATE-----', '') + response_si_certificate = response_si_certificate.replace('-----END CERTIFICATE-----', '') + response_si_certificate = response_si_certificate.replace('\n', '') + response_si_certificate = wrap(response_si_certificate, 76) + response_si_certificate = '\r\n'.join(response_si_certificate) + response_si_certificate = f'-----BEGIN CERTIFICATE-----\r\n{response_si_certificate}\r\n-----END CERTIFICATE-----' + response = { "certificateConfiguration": { - "caChain": [my_ca_certificate.public_bytes(encoding=Encoding.PEM).decode('utf-8').strip().replace('\n','\r\n')], - "publicCert": my_si_certificate.public_bytes(encoding=Encoding.PEM).decode('utf-8').strip().replace('\n','\r\n'), + # 76 chars per line + "caChain": [response_ca_chain], + # 76 chars per line + "publicCert": response_si_certificate, "publicKey": { "exp": int(my_si_certificate.public_key().public_numbers().e), "mod": [hex(my_si_certificate.public_key().public_numbers().n)[2:]],