Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Add a timeout to catch hangs during cert generation",
"packageName": "react-native-windows",
"email": "acoates@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-03-26T16:13:40.983Z"
}
5 changes: 3 additions & 2 deletions vnext/local-cli/generator-windows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ function generateCertificate(srcPath, destPath, newProjectName, currentUser) {
let toCopyTempKey = false;
if (os.platform() === 'win32') {
try {
const thumbprint = childProcess.execSync(`powershell -command "Write-Output (New-SelfSignedCertificate -KeyUsage DigitalSignature -KeyExportPolicy Exportable -Subject 'CN=${currentUser}' -TextExtension @('2.5.29.37={text}1.3.6.1.5.5.7.3.3', '2.5.29.19={text}Subject Type:End Entity') -CertStoreLocation 'Cert:\\CurrentUser\\My').Thumbprint"`).toString().trim();
const timeout = 10000; // 10 seconds;
const thumbprint = childProcess.execSync(`powershell -command "Write-Output (New-SelfSignedCertificate -KeyUsage DigitalSignature -KeyExportPolicy Exportable -Subject 'CN=${currentUser}' -TextExtension @('2.5.29.37={text}1.3.6.1.5.5.7.3.3', '2.5.29.19={text}Subject Type:End Entity') -CertStoreLocation 'Cert:\\CurrentUser\\My').Thumbprint"`, {timeout}).toString().trim();
if (!fs.existsSync(path.join(windowsDir, newProjectName))) {
fs.createDir(path.join(windowsDir, newProjectName));
}
childProcess.execSync(`powershell -command "$pwd = (ConvertTo-SecureString -String password -Force -AsPlainText); Export-PfxCertificate -Cert 'cert:\\CurrentUser\\My\\${thumbprint}' -FilePath ${path.join(windowsDir, newProjectName, newProjectName)}_TemporaryKey.pfx -Password $pwd"`);
childProcess.execSync(`powershell -command "$pwd = (ConvertTo-SecureString -String password -Force -AsPlainText); Export-PfxCertificate -Cert 'cert:\\CurrentUser\\My\\${thumbprint}' -FilePath ${path.join(windowsDir, newProjectName, newProjectName)}_TemporaryKey.pfx -Password $pwd"`, {timeout});
console.log(chalk.green('Self-signed certificate generated successfully.'));
return thumbprint;
} catch (err) {
Expand Down