diff options
Diffstat (limited to 'src/ca/snisslcert.cpp')
-rw-r--r-- | src/ca/snisslcert.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/ca/snisslcert.cpp b/src/ca/snisslcert.cpp index 466ef0b9..3a7336af 100644 --- a/src/ca/snisslcert.cpp +++ b/src/ca/snisslcert.cpp | |||
@@ -85,8 +85,8 @@ static void SetSniSslCertSetKey( | |||
85 | 85 | ||
86 | 86 | ||
87 | LPCWSTR vcsWixHttpSniSslCertQuery = | 87 | LPCWSTR vcsWixHttpSniSslCertQuery = |
88 | L"SELECT `WixHttpSniSslCert`.`WixHttpSniSslCert`, `WixHttpSniSslCert`.`Host`, `WixHttpSniSslCert`.`Port`, `WixHttpSniSslCert`.`Thumbprint`, `WixHttpSniSslCert`.`AppId`, `WixHttpSniSslCert`.`Store`, `WixHttpSniSslCert`.`HandleExisting`, `WixHttpSniSslCert`.`Component_` " | 88 | L"SELECT `Wix4HttpSniSslCert`.`Wix4HttpSniSslCert`, `Wix4HttpSniSslCert`.`Host`, `Wix4HttpSniSslCert`.`Port`, `Wix4HttpSniSslCert`.`Thumbprint`, `Wix4HttpSniSslCert`.`AppId`, `Wix4HttpSniSslCert`.`Store`, `Wix4HttpSniSslCert`.`HandleExisting`, `Wix4HttpSniSslCert`.`Component_` " |
89 | L"FROM `WixHttpSniSslCert`"; | 89 | L"FROM `Wix4HttpSniSslCert`"; |
90 | enum eWixHttpSniSslCertQuery { hurqId = 1, hurqHost, hurqPort, hurqCertificateThumbprint, hurqAppId, hurqCertificateStore, hurqHandleExisting, hurqComponent }; | 90 | enum eWixHttpSniSslCertQuery { hurqId = 1, hurqHost, hurqPort, hurqCertificateThumbprint, hurqAppId, hurqCertificateStore, hurqHandleExisting, hurqComponent }; |
91 | 91 | ||
92 | /****************************************************************** | 92 | /****************************************************************** |
@@ -320,17 +320,17 @@ static UINT SchedHttpSniSslCerts( | |||
320 | HTTP_SERVICE_CONFIG_SSL_SNI_SET* pExistingSniSslSet = NULL; | 320 | HTTP_SERVICE_CONFIG_SSL_SNI_SET* pExistingSniSslSet = NULL; |
321 | 321 | ||
322 | // Anything to do? | 322 | // Anything to do? |
323 | hr = WcaTableExists(L"WixHttpSniSslCert"); | 323 | hr = WcaTableExists(L"Wix4HttpSniSslCert"); |
324 | ExitOnFailure(hr, "Failed to check if the WixHttpSniSslCert table exists"); | 324 | ExitOnFailure(hr, "Failed to check if the Wix4HttpSniSslCert table exists"); |
325 | if (S_FALSE == hr) | 325 | if (S_FALSE == hr) |
326 | { | 326 | { |
327 | WcaLog(LOGMSG_STANDARD, "WixHttpSniSslCert table doesn't exist, so there are no URL reservations to configure"); | 327 | WcaLog(LOGMSG_STANDARD, "Wix4HttpSniSslCert table doesn't exist, so there are no URL reservations to configure"); |
328 | ExitFunction(); | 328 | ExitFunction(); |
329 | } | 329 | } |
330 | 330 | ||
331 | // Query and loop through all the SNI SSL certificates. | 331 | // Query and loop through all the SNI SSL certificates. |
332 | hr = WcaOpenExecuteView(vcsWixHttpSniSslCertQuery, &hView); | 332 | hr = WcaOpenExecuteView(vcsWixHttpSniSslCertQuery, &hView); |
333 | ExitOnFailure(hr, "Failed to open view on the WixHttpSniSslCert table"); | 333 | ExitOnFailure(hr, "Failed to open view on the Wix4HttpSniSslCert table"); |
334 | 334 | ||
335 | hr = HRESULT_FROM_WIN32(::HttpInitialize(HTTPAPI_VERSION_1, HTTP_INITIALIZE_CONFIG, NULL)); | 335 | hr = HRESULT_FROM_WIN32(::HttpInitialize(HTTPAPI_VERSION_1, HTTP_INITIALIZE_CONFIG, NULL)); |
336 | ExitOnFailure(hr, "Failed to initialize HTTP Server configuration"); | 336 | ExitOnFailure(hr, "Failed to initialize HTTP Server configuration"); |
@@ -340,66 +340,66 @@ static UINT SchedHttpSniSslCerts( | |||
340 | while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) | 340 | while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) |
341 | { | 341 | { |
342 | hr = WcaGetRecordString(hRec, hurqId, &sczId); | 342 | hr = WcaGetRecordString(hRec, hurqId, &sczId); |
343 | ExitOnFailure(hr, "Failed to get WixHttpSniSslCert.WixHttpSniSslCert"); | 343 | ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Wix4HttpSniSslCert"); |
344 | 344 | ||
345 | hr = WcaGetRecordString(hRec, hurqComponent, &sczComponent); | 345 | hr = WcaGetRecordString(hRec, hurqComponent, &sczComponent); |
346 | ExitOnFailure(hr, "Failed to get WixHttpSniSslCert.Component_"); | 346 | ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Component_"); |
347 | 347 | ||
348 | // Figure out what we're doing for this reservation, treating reinstall the same as install. | 348 | // Figure out what we're doing for this reservation, treating reinstall the same as install. |
349 | todoComponent = WcaGetComponentToDo(sczComponent); | 349 | todoComponent = WcaGetComponentToDo(sczComponent); |
350 | if ((WCA_TODO_REINSTALL == todoComponent ? WCA_TODO_INSTALL : todoComponent) != todoSched) | 350 | if ((WCA_TODO_REINSTALL == todoComponent ? WCA_TODO_INSTALL : todoComponent) != todoSched) |
351 | { | 351 | { |
352 | WcaLog(LOGMSG_STANDARD, "Component '%ls' action state (%d) doesn't match request (%d) for WixHttpSniSslCert '%ls'", sczComponent, todoComponent, todoSched, sczId); | 352 | WcaLog(LOGMSG_STANDARD, "Component '%ls' action state (%d) doesn't match request (%d) for Wix4HttpSniSslCert '%ls'", sczComponent, todoComponent, todoSched, sczId); |
353 | continue; | 353 | continue; |
354 | } | 354 | } |
355 | 355 | ||
356 | hr = WcaGetRecordFormattedString(hRec, hurqHost, &sczHost); | 356 | hr = WcaGetRecordFormattedString(hRec, hurqHost, &sczHost); |
357 | ExitOnFailure(hr, "Failed to get WixHttpSniSslCert.Host"); | 357 | ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Host"); |
358 | 358 | ||
359 | hr = WcaGetRecordFormattedInteger(hRec, hurqPort, &iPort); | 359 | hr = WcaGetRecordFormattedInteger(hRec, hurqPort, &iPort); |
360 | ExitOnFailure(hr, "Failed to get WixHttpSniSslCert.Port"); | 360 | ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.Port"); |
361 | 361 | ||
362 | hr = WcaGetRecordFormattedString(hRec, hurqCertificateThumbprint, &sczCertificateThumbprint); | 362 | hr = WcaGetRecordFormattedString(hRec, hurqCertificateThumbprint, &sczCertificateThumbprint); |
363 | ExitOnFailure(hr, "Failed to get WixHttpSniSslCert.CertificateThumbprint"); | 363 | ExitOnFailure(hr, "Failed to get Wix4HttpSniSslCert.CertificateThumbprint"); |
364 | 364 | ||
365 | if (!sczHost || !*sczHost) | 365 | if (!sczHost || !*sczHost) |
366 | { | 366 | { |
367 | hr = E_INVALIDARG; | 367 | hr = E_INVALIDARG; |
368 | ExitOnFailure(hr, "Require a Host value for WixHttpSniSslCert '%ls'", sczId); | 368 | ExitOnFailure(hr, "Require a Host value for Wix4HttpSniSslCert '%ls'", sczId); |
369 | } | 369 | } |
370 | 370 | ||
371 | if (!iPort) | 371 | if (!iPort) |
372 | { | 372 | { |
373 | hr = E_INVALIDARG; | 373 | hr = E_INVALIDARG; |
374 | ExitOnFailure(hr, "Require a Port value for WixHttpSniSslCert '%ls'", sczId); | 374 | ExitOnFailure(hr, "Require a Port value for Wix4HttpSniSslCert '%ls'", sczId); |
375 | } | 375 | } |
376 | 376 | ||
377 | if (!sczCertificateThumbprint || !*sczCertificateThumbprint) | 377 | if (!sczCertificateThumbprint || !*sczCertificateThumbprint) |
378 | { | 378 | { |
379 | hr = E_INVALIDARG; | 379 | hr = E_INVALIDARG; |
380 | ExitOnFailure(hr, "Require a CertificateThumbprint value for WixHttpSniSslCert '%ls'", sczId); | 380 | ExitOnFailure(hr, "Require a CertificateThumbprint value for Wix4HttpSniSslCert '%ls'", sczId); |
381 | } | 381 | } |
382 | 382 | ||
383 | hr = WcaGetRecordFormattedString(hRec, hurqAppId, &sczAppId); | 383 | hr = WcaGetRecordFormattedString(hRec, hurqAppId, &sczAppId); |
384 | ExitOnFailure(hr, "Failed to get AppId for WixHttpSniSslCert '%ls'", sczId); | 384 | ExitOnFailure(hr, "Failed to get AppId for Wix4HttpSniSslCert '%ls'", sczId); |
385 | 385 | ||
386 | hr = WcaGetRecordFormattedString(hRec, hurqCertificateStore, &sczCertificateStore); | 386 | hr = WcaGetRecordFormattedString(hRec, hurqCertificateStore, &sczCertificateStore); |
387 | ExitOnFailure(hr, "Failed to get CertificateStore for WixHttpSniSslCert '%ls'", sczId); | 387 | ExitOnFailure(hr, "Failed to get CertificateStore for Wix4HttpSniSslCert '%ls'", sczId); |
388 | 388 | ||
389 | hr = WcaGetRecordInteger(hRec, hurqHandleExisting, &iHandleExisting); | 389 | hr = WcaGetRecordInteger(hRec, hurqHandleExisting, &iHandleExisting); |
390 | ExitOnFailure(hr, "Failed to get HandleExisting for WixHttpSniSslCert '%ls'", sczId); | 390 | ExitOnFailure(hr, "Failed to get HandleExisting for Wix4HttpSniSslCert '%ls'", sczId); |
391 | 391 | ||
392 | hr = GetSniSslCert(sczHost, iPort, &pExistingSniSslSet); | 392 | hr = GetSniSslCert(sczHost, iPort, &pExistingSniSslSet); |
393 | ExitOnFailure(hr, "Failed to get the existing SNI SSL certificate for WixHttpSniSslCert '%ls'", sczId); | 393 | ExitOnFailure(hr, "Failed to get the existing SNI SSL certificate for Wix4HttpSniSslCert '%ls'", sczId); |
394 | 394 | ||
395 | hr = EnsureAppId(&sczAppId, pExistingSniSslSet); | 395 | hr = EnsureAppId(&sczAppId, pExistingSniSslSet); |
396 | ExitOnFailure(hr, "Failed to ensure AppId for WixHttpSniSslCert '%ls'", sczId); | 396 | ExitOnFailure(hr, "Failed to ensure AppId for Wix4HttpSniSslCert '%ls'", sczId); |
397 | 397 | ||
398 | hr = WriteExistingSniSslCert(todoComponent, sczId, sczHost, iPort, iHandleExisting, pExistingSniSslSet, &sczRollbackCustomActionData); | 398 | hr = WriteExistingSniSslCert(todoComponent, sczId, sczHost, iPort, iHandleExisting, pExistingSniSslSet, &sczRollbackCustomActionData); |
399 | ExitOnFailure(hr, "Failed to write rollback custom action data for WixHttpSniSslCert '%ls'", sczId); | 399 | ExitOnFailure(hr, "Failed to write rollback custom action data for Wix4HttpSniSslCert '%ls'", sczId); |
400 | 400 | ||
401 | hr = WriteSniSslCert(todoComponent, sczId, sczHost, iPort, iHandleExisting, sczCertificateThumbprint, sczAppId, sczCertificateStore, &sczCustomActionData); | 401 | hr = WriteSniSslCert(todoComponent, sczId, sczHost, iPort, iHandleExisting, sczCertificateThumbprint, sczAppId, sczCertificateStore, &sczCustomActionData); |
402 | ExitOnFailure(hr, "Failed to write custom action data for WixHttpSniSslCert '%ls'", sczId); | 402 | ExitOnFailure(hr, "Failed to write custom action data for Wix4HttpSniSslCert '%ls'", sczId); |
403 | ++cCertificates; | 403 | ++cCertificates; |
404 | 404 | ||
405 | ReleaseNullMem(pExistingSniSslSet); | 405 | ReleaseNullMem(pExistingSniSslSet); |
@@ -410,7 +410,7 @@ static UINT SchedHttpSniSslCerts( | |||
410 | { | 410 | { |
411 | hr = S_OK; | 411 | hr = S_OK; |
412 | } | 412 | } |
413 | ExitOnFailure(hr, "Failure occurred while processing WixHttpSniSslCert table"); | 413 | ExitOnFailure(hr, "Failure occurred while processing Wix4HttpSniSslCert table"); |
414 | 414 | ||
415 | // Schedule ExecHttpSniSslCerts if there's anything to do. | 415 | // Schedule ExecHttpSniSslCerts if there's anything to do. |
416 | if (cCertificates) | 416 | if (cCertificates) |
@@ -475,16 +475,16 @@ static HRESULT WriteExistingSniSslCert( | |||
475 | if (pSniSslSet) | 475 | if (pSniSslSet) |
476 | { | 476 | { |
477 | hr = StrAllocHexEncode(reinterpret_cast<BYTE*>(pSniSslSet->ParamDesc.pSslHash), pSniSslSet->ParamDesc.SslHashLength, &sczCertificateThumbprint); | 477 | hr = StrAllocHexEncode(reinterpret_cast<BYTE*>(pSniSslSet->ParamDesc.pSslHash), pSniSslSet->ParamDesc.SslHashLength, &sczCertificateThumbprint); |
478 | ExitOnFailure(hr, "Failed to convert existing certificate thumbprint to hex for WixHttpSniSslCert '%ls'", wzId); | 478 | ExitOnFailure(hr, "Failed to convert existing certificate thumbprint to hex for Wix4HttpSniSslCert '%ls'", wzId); |
479 | 479 | ||
480 | hr = StringFromGuid(pSniSslSet->ParamDesc.AppId, &sczAppId); | 480 | hr = StringFromGuid(pSniSslSet->ParamDesc.AppId, &sczAppId); |
481 | ExitOnFailure(hr, "Failed to copy existing AppId for WixHttpSniSslCert '%ls'", wzId); | 481 | ExitOnFailure(hr, "Failed to copy existing AppId for Wix4HttpSniSslCert '%ls'", wzId); |
482 | 482 | ||
483 | wzCertificateStore = pSniSslSet->ParamDesc.pSslCertStoreName; | 483 | wzCertificateStore = pSniSslSet->ParamDesc.pSslCertStoreName; |
484 | } | 484 | } |
485 | 485 | ||
486 | hr = WriteSniSslCert(action, wzId, wzHost, iPort, iHandleExisting, sczCertificateThumbprint ? sczCertificateThumbprint : L"", sczAppId ? sczAppId : L"", wzCertificateStore ? wzCertificateStore : L"", psczCustomActionData); | 486 | hr = WriteSniSslCert(action, wzId, wzHost, iPort, iHandleExisting, sczCertificateThumbprint ? sczCertificateThumbprint : L"", sczAppId ? sczAppId : L"", wzCertificateStore ? wzCertificateStore : L"", psczCustomActionData); |
487 | ExitOnFailure(hr, "Failed to write custom action data for WixHttpSniSslCert '%ls'", wzId); | 487 | ExitOnFailure(hr, "Failed to write custom action data for Wix4HttpSniSslCert '%ls'", wzId); |
488 | 488 | ||
489 | LExit: | 489 | LExit: |
490 | ReleaseStr(sczAppId); | 490 | ReleaseStr(sczAppId); |