簡體   English   中英

如何在不使用 github 中的機密的情況下安全地簽署 Android apk?

[英]How to sign an Android apk securely without using secrets in github?

https://overflow.buffer.com/2020/05/07/using-github-actions-for-android-continuous-integration-and-delivery/

我閱讀了此處的指南,並設法設置了 Github 操作以生成簽名的 apk。 是否可以在不使用 Github 中的機密的情況下簽署 Android apk? 如果可能的話,我想將密鑰庫 jks 和 rest 的詳細信息(例如別名)存儲到單獨的雲服務器,比如說 Google 驅動器。 我能否檢索密鑰庫和詳細信息並以某種方式將它們導入 Github CI 腳本? 我試圖實現的最終目標是找到最安全的方式來簽署 apk,我仍在尋找解決方案。

如果您不想使用 GitHub 機密,可以將簽名信息(密碼和別名)提取到單獨的文件中,如此所述。

(所有示例均來自上面的鏈接)

使用以下內容創建文件keystore.properties

storePassword=myStorePassword
keyPassword=mykeyPassword
keyAlias=myKeyAlias
storeFile=myStoreFileLocation

閱讀 gradle 腳本中的文件內容:

...

// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")

// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()

// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    ...
}

設置簽名配置:

android {
    signingConfigs {
        config {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    ...
  }

在您的 CI 工作中,您必須以某種方式下載密鑰庫並提取簽名信息。 例如通過使用curl

盡管如此,這仍然沒有增加安全性。 如果您要公開托管您的密鑰庫和簽名信息,那么每個人都可以下載它。 如果您只使用密碼/API 密鑰訪問它,則必須向您的 CI 提供此密碼/API 密鑰。 理想情況下,通過 GitHub 機密。

我不知道您的用例,但一般來說,我建議您使用 GitHub 機密(或任何其他機密功能,如果您使用不同的 CI)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM