跳转到正文

加密

本文档介绍了如何迁移到 encryption v2 系统。欲了解更多关于 encryption v2 系统的信息,请参阅 博客文章.

终端窗口
npx @capgo/cli key create

请安全地存储私钥。切勿将其提交至版本控制系统,或将其分享给不可信的第三方。

该命令将:

  • 在您的应用中创建新的密钥对
  • 从 Capacitor 配置中移除旧密钥
  • 保留旧密钥文件以确保向后兼容性

When prompted “Do you want to setup encryption with the new channel in order to support old apps and facilitate the migration?”, select yes. This adds a new defaultChannel 添加到您的 Capacitor 配置选项中。

capacitor.config.ts
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
appId: 'com.example.app',
appName: 'Example App',
plugins: {
CapacitorUpdater: {
// ... other options
defaultChannel: 'encryption_v2' // New apps will use this channel
}
}
};
export default config;
终端窗口
npx @capgo/cli bundle upload --channel encryption_v2
终端窗口
npx @capgo/cli channel set encryption_v2 --self-assign
终端窗口
npx @capgo/cli bundle upload --channel production

当所有用户都已更新应用后:

  1. 移除 defaultChannel 从 Capacitor 配置中移除
  2. 删除旧 channel:
终端窗口
npx @capgo/cli channel delete encryption_v2

如果你正在使用 加密 来规划安全与合规,请结合 加密 了解 Encryption 的实现细节, 合规性 了解合规部分的实现细节, Capgo 安全扫描器 了解 Capgo Security Scanner 的产品工作流, Capgo 安全 用于 Capgo 安全的产品工作流,以及 Capgo 信任中心 用于 Capgo 信任中心的产品工作流。