Managing Certificates for Application Testing

证书管理与应用签名
本文介绍了如何管理和使用测试证书,包括将证书添加到个人证书存储和个人设备中,确定设备的安全配置,查询设备证书存储中的证书,以及应用程序的测试和分发签名。此外,还详细说明了数字证书文件的导入、导出及查看过程。


A.     Adding Test Certificates to the Certificate Store and Devices

You need to add test certificates to the following:

Personal certificate store on the computer used to develop applications

Windows Mobile-based device

You add certificates to the device by using the RAPIConfig.exe application and a provisioning .xml file.

To add the certificates to the personal certificate store

For the privileged certificate, open Windows Explorer and double-click the TestCert_Privileged.pfx file located at C:/Program Files/Windows CE Tools/wce500/<platform>/Tools.

Click Next three times. A password is not associated with this certificate.

Confirm that Automatically select the certificate store based on the type of certificate is selected, and then click Next.

Click Finish.

For the unprivileged certificate, double-click the TestCert_UnPrivileged.pfx file located at C:/Program Files/Windows CE Tools/wce420/<platform>/Tools, and then repeat steps 2–4.

To add the certificates to the device

Connect the Windows Mobile-based device to the computer using ActiveSync.

Open a command prompt window, and change to the folder that contains the RAPIConfig.exe application and the sdktestcerts.xml file. The files are located at C:/Program Files/Windows CE Tools/wce500/<platform>/Tools.

At the command prompt, type RAPIConfig.exe /p sdktestcerts.xml, and then press ENTER.

B.     Determining the Security Configuration of the Device

If the device security configuration requires signed binary files and the application binary files are unsigned, the application will not run. You can use provisioning XML and the SecurityPolicy Configuration Service Provider to determine the security configuration of the device.

C.      Querying for Certificates Contained in the Device Certificate Store

If your application fails to install or run, it may be signed with a certificate that does not match any of the root certificates contained in the device certificate store. You can use provisioning XML and the CertificateStore Configuration Service Provider to determine which certificates are contained in the certificate store.

To query for certificates contained in the device certificate store

Create the provisioning XML document.

Save the XML document as an ASCII file.

Add the .xml file to an installation .cab file by doing the following:

Open a command prompt window and change to the C:/Program Files/Windows CE Tools/wce500/Windows Mobile 5.0 Pocket PC SDK/ folder for Pocket PC, or C:/Program Files/Windows CE Tools/wce500/Windows Mobile 5.0 Smartphone SDK/ folder for Smartphone.

Run the makecab.exe tool as follows:

For Windows Mobile-based Smartphones: makecab XML file name myprovxml.cab

For Windows Mobile-based Pocket PCs: makecab /D COMPRESS=OFF XML file name myprovxml.cab

Note   /D COMPRESS=OFF turns off file compression, which Windows Mobile software for Pocket PCs requires.

Sign the .cab file using signtool.

D.    Signing Applications for Testing and Distribution

You sign .cab and binary files using signtool.exe. This will enable you to certify and distribute the application through the Microsoft Mobile2Market program.

E.      Importing and Exporting Test Certificates

a)      Installing the PVK Digital Certificate Files Importer

You can use the PVK Digital Certificate File Importer tool for packaging import and export certificate files.

To download and install the PVK Digital Certificate Files Importer

Download the PvkImprt.exe setup program, located at PVK Digital Certificate Files Importer.

Double-click the file.

Follow the instructions on the screen.

You can also use the command line to install for the application. The following example shows the syntax for installing from the command line.

pvkimprt [option]

The following table shows the command line options for the installation.

Option

Description

/Q

Quiet mode for the installation package

/T:<full path>

Specifies a temporary working folder

/C

When used with the /T option, extracted for folder specified

/C:<Cmd>

Overrides the install command defined by author

b)     Importing Digital Certificate Files into the Personal Certificate Store

You can import the digital certificate files (.cer or .spc file and a .pvk key pair file) into the personal certificate store on a computer by running PVK Digital Certificate Importer (PvkImprt.exe) with the -IMPORT option.

To import the digital certificate files into the Personal certificate store

Open a command prompt window.

Type PVKIMPRT -IMPORT and the full path of the .cer or .spc file and a .pvk file.

The following example shows the syntax for using PvkImport.exe to import the .cer or .spc file and a .pvk key pair file:

<full directory path/>PvkImprt -import <full directory path/><.spc or .cer file> ,<full directory path/><.pvk file>

In the following example, the TestCert_Privileged.cer and TestCert_Privileged.pvk files are imported:

C:/SDK/Tools/pvkimprt -import C:/SDK/Tools/TestCert_Privileged.cer C:/SDK/Tools/TestCert_Privileged.pvk

Click Next, and then select Place all certificates in the following store.

Click Finish.

The import was successful message displays.

To confirm that the import was successful, view the certificate in the personal certificate store.

 

 

c)      Packaging Digital Certificate Files for Export

You can package digital certificate files (.cer or .spc and .pvk) in a .pfx file. A .pfx file is encrypted according to the PKCS #12 standard and a single password helps protect a .pfx file. Packaging enables you to back up the files and import them into the personal certificate store on another computer.

Run the PvkImprt tool from the directory you installed it in, or supply the complete path to the install directory.

To package digital certificate files in a .pfx file for export

Open a command prompt window.

Type PVKIMPRT -PFX and full path of the .cer or .spc file and a .pvk file.

The following example shows the syntax for packaging files in a .pfx file:

<Full directory path/>pvkimprt -PFX <Full directory path/><.cer or .spc file name> <Full directory path/><.pvk file name>

In the following example, the TestCert_Privileged.cer and TestCert_Privileged.pvk files are packaged in a .pfx file:

pvkimprt -PFX c:/SDK/Tools/TestCert_Privileged.cer c:/SDK/Tools/TestCert_Privileged.pvk

Click Next.

Select Yes, export the private key, and then click Next.

Select Enable strong protection, and then click Next.

Select Personal Information Exchange - PKCS#12 (.PFX).

Type the password you want to use to help protect the file, and then click Next.

Type the file name or click Browse to select the file, and then click Finish.

d)     Viewing Certificates in the Personal Certificate Store

You can use Microsoft Internet Explorer to view certificates in the personal certificate store.

To view certificates using Internet Explorer

Open Internet Explorer.

On the Tools menu, click Internet Options.

Click the Content tab, and then click Certificates.

Click the Personal tab to view the certificates in the personal certificate store

You should have access rights to the private keys of all certificates in the personal certificate store. You can determine whether you have access rights to a private key by double-clicking a certificate to view the certificate information.

e)     Troubleshooting the PVK Digital Certificate Files Importer

Due to a difference in default key lengths between Microsoft® Windows® Millennium, Microsoft® Windows® XP and other versions of Windows, the PvkImprt.exe tool may fail when used to import keys between Windows Millennium or Windows XP and other Windows platforms. You can solve this problem by doing the following:

Use PvkImprt.exe to export the .pvk and .spc or .cer files as type .pfx on a Windows platform that is the same as the one on which the keys were generated. For example, if the key pair was generated on a Windows Millennium or Windows XP computer, perform the .pfx export on a Windows Millennium or Windows XP computer.

Once the keys have been exported as type .pfx, they can be imported on any Windows platform using a certificate import tool. For example you could import the files by using the Certificate Import Wizard.

 

 

 

 

在使用 Chrome 浏览器或基于 Chrome 的自动化工具(如 Selenium)时,出现 `error sending request for URL` 异常,通常与网络请求失败、版本不兼容、驱动程序配置不当或远程服务不可用有关。以下是常见的原因及对应的解决方法。 ### 1. ChromeDriver 与 Chrome 浏览器版本不兼容 当使用的 `ChromeDriver` 版本与当前安装的 `Chrome` 浏览器版本不匹配时,会导致 `SessionNotCreatedException` 或请求失败的问题。例如,若 `ChromeDriver` 支持的是 Chrome 121,而系统中安装的是 Chrome 130,则会提示版本不兼容 [^2]。 **解决方法:** - 确认当前 Chrome 浏览器的版本(可在 `chrome://settings/help` 查看)。 - 下载与该版本匹配的 [ChromeDriver](https://googlechromelabs.github.io/chrome-for-testing/)。 - 替换旧的 `chromedriver.exe` 文件,并确保其路径未被其他旧版本污染。 ### 2. 网络请求失败(如访问 `known-good-versions-with-downloads.json` 失败) 自动化工具在启动时可能尝试访问远程资源(如 `https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json`)以获取兼容版本信息。如果网络连接受限、代理配置错误或防火墙拦截,会导致请求失败 [^1]。 **解决方法:** - 检查网络连接是否正常,尝试手动访问上述 URL。 - 如果使用了代理,确保在代码或系统中正确配置代理设置。 - 在代码中禁用自动检查版本(如通过设置 `options.add_argument('--disable-background-networking')`)。 ### 3. ChromeDriver 路径冲突 系统 `PATH` 环境变量中可能包含多个 `chromedriver.exe`,导致程序加载了错误的驱动程序版本,从而引发兼容性问题 [^1]。 **解决方法:** - 检查系统 `PATH` 中所有包含 `chromedriver.exe` 的路径。 - 删除或重命名旧版本的 `chromedriver.exe`。 - 在启动脚本中显式指定正确的 `chromedriver` 路径,例如: ```python from selenium import webdriver options = webdriver.ChromeOptions() driver = webdriver.Chrome(executable_path='/path/to/correct/chromedriver', options=options) ``` ### 4. Plausible.io 请求失败(如统计信息发送失败) 某些自动化工具会尝试将使用情况统计信息发送到远程服务(如 Plausible.io),如果该服务不可达或被屏蔽,会抛出 `Error sending stats` 类似的异常 。 **解决方法:** - 如果不需要统计功能,可以在启动时禁用相关设置。 - 对于 Selenium,可以尝试添加如下参数: ```python options.add_argument('--disable-usage-statistics') ``` ### 5. 驱动程序或浏览器被安全软件拦截 某些杀毒软件或防火墙可能会拦截 ChromeDriver 与浏览器之间的通信,导致连接失败。 **解决方法:** - 暂时关闭杀毒软件或防火墙进行测试。 - 将 `chromedriver.exe` 和浏览器添加到信任列表中。 ### 6. 使用无头模式时的额外配置问题 如果使用了无头模式(headless),某些网站可能会检测到自动化行为并阻止请求。 **解决方法:** - 添加如下参数以规避检测: ```python options.add_argument('--headless=new') options.add_argument('--disable-blink-features=AutomationControlled') options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') ``` ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值