More unicode compat / more fix

This commit is contained in:
hakril
2024-05-20 19:00:06 +02:00
parent 1b5097050b
commit a580d825ae
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -92,7 +92,7 @@ def rawpfx():
return b64decode(TEST_PFX)
PFW_TEST_TMP_KEY_CONTAINER = "PythonForWindowsTMPContainerTest"
RANDOM_CERTIF_NAME = b"PythonForWindowsGeneratedRandomCertifTest"
RANDOM_CERTIF_NAME = "PythonForWindowsGeneratedRandomCertifTest"
RANDOM_PFX_PASSWORD = "PythonForWindowsGeneratedRandomPFXPassword"
@pytest.fixture()
@@ -125,7 +125,7 @@ def randomkeypair(keysize=1024):
crypt_algo.pszObjId = gdef.szOID_RSA_SHA256RSA.encode("ascii") # do something else (bytes in generated ctypes ?)
# This is fucking dumb, there is no .format on bytes object...
certif_name = b"".join((b"CN=", RANDOM_CERTIF_NAME))
certif_name = "".join(("CN=", RANDOM_CERTIF_NAME))
# Generate a self-signed certificate based on the given key-container and signature algorithme
certif = windows.crypto.generation.generate_selfsigned_certificate(certif_name, key_info=KeyProvInfo, signature_algo=crypt_algo)
# Add the newly created certificate to our TMP cert-store
+1 -1
View File
@@ -13,7 +13,7 @@ def generate_selfsigned_certificate(name="CN=DEFAULT", prov=None, key_info=None,
"""
size = ULONG(len(name) + 0x100)
buffer = (ctypes.c_ubyte * size.value)()
winproxy.CertStrToNameA(X509_ASN_ENCODING, name, CERT_OID_NAME_STR, None, buffer, size, None)
winproxy.CertStrToNameW(X509_ASN_ENCODING, name, CERT_OID_NAME_STR, None, buffer, size, None)
blobname = CRYPT_DATA_BLOB(size.value, buffer)
cert = winproxy.CertCreateSelfSignCertificate(prov, blobname, flags, key_info, signature_algo, None, None, None)
return windows.crypto.Certificate.from_pointer(cert)
+1 -1
View File
@@ -36,7 +36,7 @@ if is_py3:
repr_encoding = sys.stdout.encoding or locale.getpreferredencoding()
def urepr_encode(s):
return ustr.encode(repr_encoding, "backslashreplace")
return s.encode(repr_encoding, "backslashreplace")
else: # py2.7
def str_from_ascii_function(s):