Search code examples
androidrsakeystoreandroid-keystore

How to create an Android keystore RSA key with infinite validity?


Here is how Google suggests creating an Android keystore:

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name \
  -keyalg RSA -keysize 2048 -validity 10000

While 10000 days may seem like eternity, 27 years could pass quicker than you think, and RSA might still be in use.
If tweaking a command-line argument now has a 0.01% chance of saving my market share in the future, I am willing to do it.

QUESTION: How to make this validity period as long as possible?


Solution

  • "1000 years" example:

    I have created "1000 years" JKS keystore without problem as well:

    keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 365000

    Then, checked for expiration period:

    keytool -list -v -keystore my-release-key.keystore

    Enter keystore password:  
    
    Keystore type: JKS
    Keystore provider: SUN
    
    Your keystore contains 1 entry
    ...
    Valid from: Tue Aug 04 15:28:01 BST 2015 until: Mon Dec 05 14:28:01 GMT 3014
    

    So, the key is valid until Mon Dec 05 14:28:01 GMT 3014