我是否应该将Android应用的发布密钥存储区提交到团队存储库?

时间:2015-11-18 12:30:23

标签: android git android-studio

我们正在开发团队中的Android应用程序。要创建签名发布apk,您应该设置密钥存储路径,密码,密钥别名和密钥密码。如果我想要我和我的团队成员可以创建具有相同签名的签名apk,我应该将密钥库文件提交给源代码控制吗?

2 个答案:

答案 0 :(得分:24)

你不应该。

Release keystore是最敏感的数据。

在我的团队中,只有一个人可以签署发布包。 (可能是一个备份)。

忽略所有敏感信息必须,我们会参考这些信息。

在我的团队中,我们配置如下:

Android Studio

/local.properties档案:

storeFile=[path/to/keystore/file]
keyAlias=[alias's key]
keyPassword=[alias's password]
storePassword=[key's password]

/app/build.gradleconfig范围:

signingConfigs {
  release {
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    storeFile file(properties.getProperty('storeFile'))
    keyAlias properties.getProperty('keyAlias')
    storePassword properties.getProperty('storePassword')
    keyPassword properties.getProperty('keyPassword')
  }
}

buildTypes {
  release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    signingConfig signingConfigs.release
  }
  .
  .
  .
}

请参阅我的完整演示配置:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    defaultConfig {
        multiDexEnabled = true

        applicationId "com.appconus.demoapp"
        minSdkVersion 16
        targetSdkVersion 21
        multiDexEnabled = true
        versionCode 18
        versionName "1.3"
    }

    signingConfigs {
        release {
            Properties properties = new Properties()
            properties.load(project.rootProject.file('local.properties').newDataInputStream())
            storeFile file(properties.getProperty('storeFile'))
            keyAlias properties.getProperty('keyAlias')
            storePassword properties.getProperty('storePassword')
            keyPassword properties.getProperty('keyPassword')
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        applicationVariants.all { variant ->
            appendVersionNameVersionCode(variant, defaultConfig)
        }
    }
}
dependencies {
    compile 'com.google.android.gms:play-services:8.1.0'
}

答案 1 :(得分:-2)

继续:

  • 它是AES加密的
  • 您可以将凭据保留在源代码控制范围之外(例如KeePass,Beyond Trust)
  • 没有凭据,任何人都无法访问密钥

但是,它也有缺点:检入时会带来一些被暴力破解的风险。因此,您应该进行成本效益分析并弄清楚这是否值得。


另一个要考虑的因素是您的组织已经在使用什么进行配置管理。如果您拥有像Azure DevOps(TFS / VSTS)这样的系统,则应尝试利用它。如果您有秘密管理员,则应该与之集成。

需要权衡:

+---------------------------+-------------------+------+--------+--------+------------------------+
|         Approach          |      Example      | Easy | Simple | Secure | Separation of Concerns |
+---------------------------+-------------------+------+--------+--------+------------------------+
| Config management system  | Azure DevOps      |      |        | X      | X                      |
| Private repo: unencrypted | Cleartext secrets | X    | X      |        |                        |
| Private repo: encrypted   | git-secret        |      | X      | X      |                        |
| Secret manager            | Azure Key Vault   |      |        | X      | X                      |
+---------------------------+-------------------+------+--------+--------+------------------------+

就我个人而言,如果我是在大型组织中进行设置的,那么我会四处找一个秘密经理。对于个人项目或小型团队,我只需提交密钥库并将凭据保留在其他位置。这取决于范围,风险以及可用的基础架构。