aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/x509/certstor_system_windows/certstor_windows.cpp19
-rw-r--r--src/lib/x509/certstor_system_windows/info.txt2
2 files changed, 10 insertions, 11 deletions
diff --git a/src/lib/x509/certstor_system_windows/certstor_windows.cpp b/src/lib/x509/certstor_system_windows/certstor_windows.cpp
index 164527fb5..f2c5a771c 100644
--- a/src/lib/x509/certstor_system_windows/certstor_windows.cpp
+++ b/src/lib/x509/certstor_system_windows/certstor_windows.cpp
@@ -11,24 +11,24 @@
#include <array>
#include <vector>
-#include <iostream>
#define NOMINMAX 1
#define _WINSOCKAPI_ // stop windows.h including winsock.h
#include <Windows.h>
#include <Wincrypt.h>
+namespace Botan {
namespace {
-const std::array<std::string, 4> cert_store_names{"MY", "Root", "Trust", "CA"};
+const std::array<const char*, 2> cert_store_names{"Root", "CA"};
-HCERTSTORE openCertStore(const std::string& cert_store_name)
+HCERTSTORE openCertStore(const char* cert_store_name)
{
- auto store = CertOpenSystemStore(0, cert_store_name.c_str());
+ auto store = CertOpenSystemStore(NULL, cert_store_name);
if(!store)
{
throw Botan::Internal_Error(
- "failed to open windows certificate store '" + cert_store_name +
+ "failed to open windows certificate store '" + std::string(cert_store_name) +
"' (Error Code: " +
std::to_string(::GetLastError()) + ")");
}
@@ -128,15 +128,14 @@ class Handle_Guard
};
}
-namespace Botan {
Certificate_Store_Windows::Certificate_Store_Windows() {}
std::vector<X509_DN> Certificate_Store_Windows::all_subjects() const
{
std::vector<X509_DN> subject_dns;
- for(auto& store_name : ::cert_store_names)
+ for(auto& store_name : cert_store_names)
{
- Handle_Guard<HCERTSTORE> windows_cert_store = openCertStore(store_name.c_str());
+ Handle_Guard<HCERTSTORE> windows_cert_store = openCertStore(store_name);
Handle_Guard<PCCERT_CONTEXT> cert_context = nullptr;
// Handle_Guard::assign exchanges the underlying pointer. No RAII is needed here, because the Windows API takes care of
@@ -172,7 +171,7 @@ std::vector<std::shared_ptr<const X509_Certificate>> Certificate_Store_Windows::
blob.pbData = reinterpret_cast<BYTE*>(dn_data.data());
std::vector<std::shared_ptr<const X509_Certificate>> certs;
- for(auto& store_name : ::cert_store_names)
+ for(auto& store_name : cert_store_names)
{
Handle_Guard<HCERTSTORE> windows_cert_store = openCertStore(store_name);
Handle_Guard<PCCERT_CONTEXT> cert_context = nullptr;
@@ -204,7 +203,7 @@ Certificate_Store_Windows::find_cert_by_pubkey_sha1(
blob.cbData = static_cast<DWORD>(key_hash.size());
blob.pbData = const_cast<BYTE*>(key_hash.data());
- for(auto& store_name : ::cert_store_names)
+ for(auto& store_name : cert_store_names)
{
Handle_Guard<HCERTSTORE> windows_cert_store = openCertStore(store_name);
Handle_Guard<PCCERT_CONTEXT> cert_context = CertFindCertificateInStore(
diff --git a/src/lib/x509/certstor_system_windows/info.txt b/src/lib/x509/certstor_system_windows/info.txt
index 8c11db8f8..66e9fa9a9 100644
--- a/src/lib/x509/certstor_system_windows/info.txt
+++ b/src/lib/x509/certstor_system_windows/info.txt
@@ -11,5 +11,5 @@ certstor_windows.h
</header:public>
<libs>
-all!windows -> crypto
+windows -> crypto
</libs> \ No newline at end of file