[Cmake-commits] CMake branch, next, updated. v3.3.1-2376-gf131a52
Brad King
brad.king at kitware.com
Mon Aug 24 11:23:50 EDT 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via f131a5287a3b8a9f37fe1edef6cc95efd9ef78ef (commit)
via bdae9ffe9dcc02c110bc5344ea137a82b42c745c (commit)
via 0221184fdd5441ea2456fe1ff0fbedbeb8c1a837 (commit)
from d394212a00197cb777c5cd5b2a887a4a909110eb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f131a5287a3b8a9f37fe1edef6cc95efd9ef78ef
commit f131a5287a3b8a9f37fe1edef6cc95efd9ef78ef
Merge: d394212 bdae9ff
Author: Brad King <brad.king at kitware.com>
AuthorDate: Mon Aug 24 11:23:49 2015 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Aug 24 11:23:49 2015 -0400
Merge topic 'vs-store-phone-cert-thumbs' into next
bdae9ffe VS: Windows Store/Phone package cert thumbprint
0221184f Simplify condition for using rpcrt4 library on Windows
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bdae9ffe9dcc02c110bc5344ea137a82b42c745c
commit bdae9ffe9dcc02c110bc5344ea137a82b42c745c
Author: Gilles Khouzam <gillesk at microsoft.com>
AuthorDate: Fri Aug 21 14:15:38 2015 -0700
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 24 11:05:33 2015 -0400
VS: Windows Store/Phone package cert thumbprint
Add the PackageCertificateThumbprint property when there is a
certificate on a WindowsStore or Phone app.
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 1886519..16b9ea1 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -558,7 +558,8 @@ endif()
if(WIN32 AND NOT UNIX)
# We need the rpcrt4 library on Windows.
- target_link_libraries(CMakeLib rpcrt4)
+ # We need the crypt32 library on Windows for crypto/cert APIs.
+ target_link_libraries(CMakeLib rpcrt4 crypt32)
endif()
#
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index a117238..3780ec0 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1013,6 +1013,94 @@ std::string cmSystemTools::ComputeStringMD5(const std::string& input)
#endif
}
+//----------------------------------------------------------------------------
+std::string cmSystemTools::ComputeCertificateThumbprint(
+ const std::string& source)
+{
+ std::string thumbprint;
+
+#ifdef _WIN32
+ BYTE* certData = NULL;
+ CRYPT_INTEGER_BLOB cryptBlob;
+ HCERTSTORE certStore = NULL;
+ PCCERT_CONTEXT certContext = NULL;
+
+ HANDLE certFile = CreateFile(cmsys::Encoding::ToWide(source.c_str()).c_str(),
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if (certFile != INVALID_HANDLE_VALUE && certFile != NULL)
+ {
+ DWORD fileSize = GetFileSize(certFile, NULL);
+ if (fileSize != INVALID_FILE_SIZE)
+ {
+ certData = new BYTE[fileSize];
+ if (certData != NULL)
+ {
+ DWORD dwRead = NULL;
+ if (ReadFile(certFile, certData, fileSize, &dwRead, NULL))
+ {
+ cryptBlob.cbData = fileSize;
+ cryptBlob.pbData = certData;
+
+ // Verify that this is a valid cert
+ if (PFXIsPFXBlob(&cryptBlob))
+ {
+ // Open the certificate as a store
+ certStore = PFXImportCertStore(
+ &cryptBlob, NULL, CRYPT_EXPORTABLE);
+ if (certStore != NULL)
+ {
+ // There should only be 1 cert.
+ certContext = CertEnumCertificatesInStore(certStore,
+ certContext);
+ if (certContext != NULL)
+ {
+ // 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
+ sprintf(pHashPrint, "%02X", hashData[i]);
+ pHashPrint += 2;
+ }
+ *pHashPrint = '\0';
+ thumbprint = hashPrint;
+ }
+ CertFreeCertificateContext(certContext);
+ }
+ CertCloseStore(certStore, 0);
+ }
+ }
+ }
+ delete[] certData;
+ }
+ }
+ CloseHandle(certFile);
+ }
+#else
+ (void)source;
+ cmSystemTools::Message("ComputeCertificateThumbprint is not implemented",
+ "Error");
+#endif
+
+ return thumbprint;
+}
+
void cmSystemTools::Glob(const std::string& directory,
const std::string& regexp,
std::vector<std::string>& files)
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index fb58307..c12a1db 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -194,6 +194,9 @@ public:
/** Compute the md5sum of a string. */
static std::string ComputeStringMD5(const std::string& input);
+ ///! Get the SHA thumbprint for a certificate file
+ static std::string ComputeCertificateThumbprint(const std::string& source);
+
/**
* Run a single executable command
*
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 80b8591..28a0425 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2893,7 +2893,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
(*this->BuildFileStream) << cmVS10EscapeXML(artifactDir) <<
"\\</AppxPackageArtifactsDir>\n";
this->WriteString("<ProjectPriFullPath>"
- "$(TargetDir)resources.pri</ProjectPriFullPath>", 2);
+ "$(TargetDir)resources.pri</ProjectPriFullPath>\n", 2);
// If we are missing files and we don't have a certificate and
// aren't targeting WP8.0, add a default certificate
@@ -2911,6 +2911,13 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
this->WriteString("<", 2);
(*this->BuildFileStream) << "PackageCertificateKeyFile>"
<< pfxFile << "</PackageCertificateKeyFile>\n";
+ std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile);
+ if (!thumb.empty())
+ {
+ this->WriteString("<PackageCertificateThumbprint>", 2);
+ (*this->BuildFileStream) << thumb
+ << "</PackageCertificateThumbprint>\n";
+ }
this->WriteString("</PropertyGroup>\n", 1);
}
else if(!pfxFile.empty())
@@ -2919,6 +2926,13 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
this->WriteString("<", 2);
(*this->BuildFileStream) << "PackageCertificateKeyFile>"
<< pfxFile << "</PackageCertificateKeyFile>\n";
+ std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile);
+ if (!thumb.empty())
+ {
+ this->WriteString("<PackageCertificateThumbprint>", 2);
+ (*this->BuildFileStream) << thumb
+ << "</PackageCertificateThumbprint>\n";
+ }
this->WriteString("</PropertyGroup>\n", 1);
}
}
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0221184fdd5441ea2456fe1ff0fbedbeb8c1a837
commit 0221184fdd5441ea2456fe1ff0fbedbeb8c1a837
Author: Brad King <brad.king at kitware.com>
AuthorDate: Mon Aug 24 10:58:42 2015 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 24 10:58:42 2015 -0400
Simplify condition for using rpcrt4 library on Windows
Drop the CMAKE_BUILD_ON_VISUAL_STUDIO variable and hard-code the
condition at its only use.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 36244dd..5e13a7e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -144,17 +144,6 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
endmacro()
-
-
-
-if(NOT CMake_TEST_EXTERNAL_CMAKE)
- set(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
- if(WIN32 AND NOT UNIX AND NOT MINGW)
- set(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
- endif()
-endif()
-
-
#-----------------------------------------------------------------------
# a macro to determine the generator and ctest executable to use
# for testing. Simply to improve readability of the main script.
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 428b364..1886519 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -556,8 +556,8 @@ if(APPLE)
target_link_libraries(CMakeLib "-framework CoreFoundation")
endif()
-if(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW)
- # We need the rpcrt4 library for at least the VS7-VC10 generators.
+if(WIN32 AND NOT UNIX)
+ # We need the rpcrt4 library on Windows.
target_link_libraries(CMakeLib rpcrt4)
endif()
-----------------------------------------------------------------------
Summary of changes:
CMakeLists.txt | 11 ----
Source/CMakeLists.txt | 7 ++-
Source/cmSystemTools.cxx | 88 ++++++++++++++++++++++++++++
Source/cmSystemTools.h | 3 +
Source/cmVisualStudio10TargetGenerator.cxx | 16 ++++-
5 files changed, 110 insertions(+), 15 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list