summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-08-08 01:21:47 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2023-08-08 18:25:01 (GMT)
commit36bd3d82f8d69710eaba11f3cefc09db1a1904f5 (patch)
tree7adf97a56f0f19f27e73237d4b957f0bb26612b3 /Source/cmSystemTools.cxx
parenta4e4daceafc83f731cf8a885ef4295b4464a4749 (diff)
downloadCMake-36bd3d82f8d69710eaba11f3cefc09db1a1904f5.zip
CMake-36bd3d82f8d69710eaba11f3cefc09db1a1904f5.tar.gz
CMake-36bd3d82f8d69710eaba11f3cefc09db1a1904f5.tar.bz2
cmSystemTools: move `ComputeCertificateThumbprint` to the only consumer
There's no need to have this API on `cmSystemTools` with only a single consumer.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx76
1 files changed, 0 insertions, 76 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 74171f4..2bdc928 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -47,12 +47,6 @@
# endif
#endif
-#if !defined(CMAKE_BOOTSTRAP)
-# if defined(_WIN32)
-# include <cm/memory>
-# endif
-#endif
-
#if defined(CMake_USE_MACH_PARSER)
# include "cmMachO.h"
#endif
@@ -1307,76 +1301,6 @@ void cmSystemTools::MoveFileIfDifferent(const std::string& source,
RemoveFile(source);
}
-#ifndef CMAKE_BOOTSTRAP
-# ifdef _WIN32
-std::string cmSystemTools::ComputeCertificateThumbprint(
- const std::string& source)
-{
- std::string thumbprint;
-
- CRYPT_INTEGER_BLOB cryptBlob;
- HCERTSTORE certStore = nullptr;
- PCCERT_CONTEXT certContext = nullptr;
-
- HANDLE certFile = CreateFileW(
- cmsys::Encoding::ToWide(source.c_str()).c_str(), GENERIC_READ,
- FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
-
- if (certFile != INVALID_HANDLE_VALUE && certFile != nullptr) {
- DWORD fileSize = GetFileSize(certFile, nullptr);
- if (fileSize != INVALID_FILE_SIZE) {
- auto certData = cm::make_unique<BYTE[]>(fileSize);
- if (certData != nullptr) {
- DWORD dwRead = 0;
- if (ReadFile(certFile, certData.get(), fileSize, &dwRead, nullptr)) {
- cryptBlob.cbData = fileSize;
- cryptBlob.pbData = certData.get();
-
- // Verify that this is a valid cert
- if (PFXIsPFXBlob(&cryptBlob)) {
- // Open the certificate as a store
- certStore =
- PFXImportCertStore(&cryptBlob, nullptr, CRYPT_EXPORTABLE);
- if (certStore != nullptr) {
- // There should only be 1 cert.
- certContext =
- CertEnumCertificatesInStore(certStore, certContext);
- if (certContext != nullptr) {
- // The hash is 20 bytes
- BYTE hashData[20];
- DWORD hashLength = 20;
-
- // Buffer to print the hash. Each byte takes 2 chars +
- // terminating character
- char hashPrint[41];
- char* pHashPrint = hashPrint;
- // Get the hash property from the certificate
- if (CertGetCertificateContextProperty(
- certContext, CERT_HASH_PROP_ID, hashData, &hashLength)) {
- for (DWORD i = 0; i < hashLength; i++) {
- // Convert each byte to hexadecimal
- snprintf(pHashPrint, 3, "%02X", hashData[i]);
- pHashPrint += 2;
- }
- *pHashPrint = '\0';
- thumbprint = hashPrint;
- }
- CertFreeCertificateContext(certContext);
- }
- CertCloseStore(certStore, 0);
- }
- }
- }
- }
- }
- CloseHandle(certFile);
- }
-
- return thumbprint;
-}
-# endif
-#endif
-
void cmSystemTools::Glob(const std::string& directory,
const std::string& regexp,
std::vector<std::string>& files)