[天天解决一问题系列 - 0005] WiX Burn 如何校验chained package的合法性

问题描述:ide

项目中使用Wix burn打包,内部包含了多个MSI。有时候会遇到以下错误spa

Error 0x80091007: Failed to verify hash of payload: SetupProject1.msi 。code

问题解析:blog

首先须要了解Wix Brun校验其payload的原理,主要有以下两种状况:ci

1)若是MSI有数字签名,则根据MSI的数字签名进行校验,也就是说若是数字签名没有变,Burn不会校验MSI的内容是否变化hash

2)若是MSI无数字签名,则获取该MSI的SHA1 hash,在安装的时候校验hash。这种状况下,若是MSI的内容发生变化,则没法使用该burn进行安装,必须从新编译。it

WIX Brun 源代码 (burn\engine\cache.cpp)编译

static HRESULT VerifyThenTransferPayload(
    __in BURN_PAYLOAD* pPayload,
    __in_z LPCWSTR wzCachedPath,
    __in_z LPCWSTR wzUnverifiedPayloadPath,
    __in BOOL fMove
    )
{
。。。
 // If the payload has a certificate root public key identifier provided, verify the certificate.
    if (pPayload->pbCertificateRootPublicKeyIdentifier)
    {
        hr = CacheVerifyPayloadSignature(pPayload, wzUnverifiedPayloadPath, hFile);
        ExitOnFailure1(hr, "Failed to verify payload signature: %ls", wzCachedPath);
    }
    else if (pPayload->pCatalog) // If catalog files are specified, attempt to verify the file with a catalog file
    {
        hr = VerifyPayloadWithCatalog(pPayload, wzUnverifiedPayloadPath, hFile);
        ExitOnFailure1(hr, "Failed to verify payload signature: %ls", wzCachedPath);
    }
    else if (pPayload->pbHash) // the payload should have a hash we can use to verify it.
    {
        hr = VerifyHash(pPayload->pbHash, pPayload->cbHash, wzUnverifiedPayloadPath, hFile);
        ExitOnFailure1(hr, "Failed to verify payload hash: %ls", wzCachedPath);
    }
。。。
}

 

解决方法:class

了解了问题的原理,方法就显而易见了。原理

相关文章
相关标签/搜索