Zugriff auf Windows Local Machine Store mit Python Win32CryptPython

Python-Programme
Anonymous
 Zugriff auf Windows Local Machine Store mit Python Win32Crypt

Post by Anonymous »

Ich versuche, auf ein Zertifikat zuzugreifen, das im Windows Local Machine Store gespeichert ist. This can't be done with wincertstore, as it uses CertOpenSystemStoreA function (see remarks: https://learn.microsoft.com/en-us/windo ... stemstorea)

However CertOpenStore from pywin32 has access, I just Ich weiß nicht, wie man die richtigen Parameter übergibt.
Hier ist mein Code: < /p>

import win32crypt

# store provider
CERT_STORE_PROV_SYSTEM = 13
#dwFlags
CERT_SYSTEM_STORE_CURRENT_SERVICE = 0x0100
CERT_SYSTEM_STORE_CURRENT_USER = 0x0200
CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY = 0x0400
CERT_SYSTEM_STORE_LOCAL_MACHINE = 0x0800
CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE = 0x1000
CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY = 0x2000
CERT_SYSTEM_STORE_SERVICES = 0x4000
CERT_SYSTEM_STORE_USERS = 0x8000

store = win32crypt.CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, None, CERT_SYSTEM_STORE_LOCAL_MACHINE, "MY")
for cert in store.CertEnumCertificatesInStore():
print("1 Cert: " + str(cert))
print("2 CertEnumCertificateContextProperties: " + str(cert.CertEnumCertificateContextProperties()))
print("3 cert.Subject: " + str(win32crypt.CertNameToStr(cert.Subject)))
< /code>

Beim Ausführen erhalte ich eine Ausnahme: (-2147024809, 'certopenstore', 'falscher Parameter.') < /p>

Dokumentation von certopenstore in Pywin32: http://timgolden.me.uk/pywin32-docs/win ... _meth.html
documentaion von certopenstore in Windows Dev Center: https://learn.microsoft.com/en-us/winct ... pi/wincrys

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post