PageRenderTime 30ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/_docs/Signing_Process.md

https://gitlab.com/AntoninCurtit/fdroid-website
Markdown | 116 lines | 90 code | 26 blank | 0 comment | 0 complexity | 43a3847dbc49a726d99c76be460cdcec MD5 | raw file
  1. ---
  2. layout: page
  3. title: Signing Process
  4. ---
  5. Cryptographic signatures using public/private key parts are central to
  6. [how F-Droid](../Security_Model) provides secure app
  7. distribution. Signing keys are required to make your own releases with
  8. the F-Droid tools. Consider the location, security and backup status
  9. of your key files carefully. The keys need to remain secure for the
  10. entire lifetime of an F-Droid repo, or an Android app. The signing
  11. key is central the identity of an Android app and an F-Droid repo, so
  12. those keys must be kept safe, secure and well backed up! Also, take
  13. note that Google's directions for
  14. [securing these private keys](https://developer.android.com/studio/publish/app-signing.html#secure-key)
  15. provides only the minimal steps to take to safeguard the keys.
  16. There are two kinds of signing involved in running a repository:
  17. - the signing of the repo index itself
  18. - the standard Android APK signing process
  19. ### Repo Index Signing
  20. When setting up the repository, one of the first steps should be to
  21. generate a signing key for the repository index. This will also create
  22. a keystore, which is the file that holds the signing keys.
  23. `fdroid init` will automatically create a new signing key for an
  24. F-Droid repo. It is possible to manually create keys just like
  25. creating
  26. [Android signing keys](https://developer.android.com/studio/publish/app-signing.html#signing-manually),
  27. with a command like:
  28. ```bash
  29. keytool -genkey -v -keystore my.keystore -alias repokey \
  30. -keyalg RSA -keysize 2048 -validity 10000
  31. ```
  32. In the above, replace _my.keystore_ with the name of the keystore file
  33. to be created, and repokey with a name to identify the repo index
  34. key by. Youll be asked for a password for the keystore, AND a
  35. password for the key. They shouldnt be the same. In between, youll
  36. be asked for some identifying details which will go in the
  37. certificate.
  38. The two passwords entered go into _config.yml_, as `keystorepass` and
  39. `keypass` respectively. The path to the keystore file is set in
  40. `keystore`, and the alias you chose for the key also go into that file
  41. is called `repo_keyalias`.
  42. ### APK Signing
  43. The F-Droid tools can automatic generate and manage APK signing keys
  44. for each app that it maintains. With the repo index signing
  45. configured, all that remains to be done for package signing to work is
  46. to set the _keydname_ field in _config.yml_ to contain the same
  47. identifying details you entered before. A new key will be generated
  48. using these details, for each application that is built. If a
  49. specific key is required for a particular application, this system can
  50. be overridden using the _keyaliases_ config settings.
  51. To set up `fdroid publish`, do these steps on the same machine where
  52. you copy APKs to and run `fdroid update`. First, set _keydname_ in
  53. _config.yml_, it should be something like this:
  54. ```python
  55. keydname = "CN=example.com, O=Example Ltd, C=UK"
  56. ```
  57. Create a dir called _unsigned/_ next to the _metadata/_ and _repo/_
  58. dirs, and run these commands to move the APK into place with a new
  59. name based on _Application ID_ and _Version Code_:
  60. ```console
  61. $ cd /path/to/repobasedir
  62. $ touch metadata/com.example.app.yml
  63. $ mkdir unsigned
  64. $ cp /path/to/app-release-unsigned.apk unsigned/com.example.app_1234.apk
  65. $ fdroid publish --verbose
  66. $ fdroid update --verbose
  67. $ fdroid server update --verbose
  68. ```
  69. ### Package Signing
  70. All packages built and/or distributed using F-Droid tools can also be
  71. signed by PGP using [GnuPG](https://gnupg.org), anything from APKs to
  72. media files will be signed. This process is run with `fdroid
  73. gpgsign`. Add `gpghome` and `gpgkey` to your _config.yml_ to configure
  74. it, there is more information in
  75. [examples/config.yml][examples/config.yml].
  76. ### Hardware Security Modules
  77. Hardware Security Modules (HSMs) are specially designed pieces of
  78. hardware for securely storing and using cryptographic keys. They
  79. provide write-only storage, so that a private key can only be written
  80. to the HSM and never read off of it. _fdroidserver_ has support for
  81. using HSMs for repo signing keys.
  82. For information on how to configure an F-Droid repo to use an HSM, see
  83. the "smartcard" sections of [examples/config.yml][examples/config.yml],
  84. specifically `keystore` and `smartcardoptions`. Most likely,
  85. [OpenSC](https://github.com/OpenSC/OpenSC) will need to be set up as a
  86. PKCS11 provider for Java.
  87. For more in-depth information, see:
  88. * _fdroidserver_ example config file: [examples/config.yml](https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/examples/config.yml#L125)
  89. * [Publishing an F-Droid Repo using a Hardware Security Module]({{ site.baseurl }}/{% post_url 2020-10-05-ntrokey-signing %})
  90. * [Security in a thumb drive: the promise and pain of hardware security modules, take one!](https://guardianproject.info/2014/03/28/security-in-a-thumb-drive-the-promise-and-pain-of-hardware-security-modules-take-one/)