create-release-keystore.ps1 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. [CmdletBinding()]
  2. param(
  3. [string]$OutputPath = (Join-Path $env:USERPROFILE ".mdiop\signing\mdiop-release.jks")
  4. )
  5. $ErrorActionPreference = "Stop"
  6. $alias = "mdiop-release"
  7. $parent = Split-Path -Parent $OutputPath
  8. if (Test-Path $OutputPath) {
  9. throw "签名文件已存在,已拒绝覆盖:$OutputPath"
  10. }
  11. $keytool = (Get-Command keytool -ErrorAction Stop).Source
  12. New-Item -ItemType Directory -Path $parent -Force | Out-Null
  13. Write-Host "即将创建 MDIOP 正式 Android 签名。"
  14. Write-Host "密码由 keytool 直接读取,不会写入脚本或命令行。"
  15. Write-Host "请使用强密码,并立即录入公司密码库。"
  16. Write-Host "密钥密码提示时直接回车,保持与 keystore 密码一致,兼容 HBuilderX。"
  17. & $keytool `
  18. -genkeypair `
  19. -alias $alias `
  20. -keyalg RSA `
  21. -keysize 4096 `
  22. -sigalg SHA256withRSA `
  23. -validity 36500 `
  24. -storetype JKS `
  25. -keystore $OutputPath `
  26. -dname "CN=MDIOP, OU=Mobile, O=MDIOP, C=CN"
  27. if ($LASTEXITCODE -ne 0 -or -not (Test-Path $OutputPath)) {
  28. throw "keytool 未能创建签名文件。"
  29. }
  30. Write-Host ""
  31. Write-Host "签名已创建:$OutputPath"
  32. Write-Host "别名:$alias"
  33. Write-Host "请执行以下命令核对并记录 SHA-256:"
  34. Write-Host "keytool -list -v -keystore `"$OutputPath`" -alias $alias"
  35. Write-Host ""
  36. Write-Host "必须完成:"
  37. Write-Host "1. 将签名文件加密备份到两个独立受控位置。"
  38. Write-Host "2. 将 store/key 密码录入公司密码库,禁止发送到聊天或提交 Git。"
  39. Write-Host "3. HBuilderX 云打包选择“使用自有证书”,包名 com.mdiop.app。"