├── LICENSE ├── README.md └── platform_import_keystore /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Platform Import Keystore 2 | My own version of [keytool-importkeypair](https://github.com/getfatday/keytool-importkeypair) 3 | 4 | **A script which takes platform.x509.pem and platform.pk8 files and creates a new keystore (with given keystorepass and keypass)** 5 | 6 | This script doesn't need a keystore pre created counter to keytool-importkeypair 7 | 8 | # Installing 9 | Add platform_import_keystore to your PATH 10 | 11 | # Usage 12 |
13 | usage: platform_import_keystore [-k keystore pass] [-p key pass] [-a key alias]
14 | 
15 | 16 | # Note 17 | 18 | If your certificat (.x509.pem) or private key (.pk8) are not nammed "platform.x509.pem" or "platform.pk8" you can edit the field in the script directly. 19 | 20 | Don't esistate to pull request this project if you want to add improvment. 21 | -------------------------------------------------------------------------------- /platform_import_keystore: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | scriptname=`basename $0` 3 | pk8="platform.pk8" 4 | pem="platform.x509.pem" 5 | out="keystore.jks" 6 | 7 | # informations should be passed by argument. 8 | alias="" 9 | keystorepass="" 10 | keypass="" 11 | 12 | usage() { 13 | cat << EOF 14 | usage: ${scriptname} [-k keystore pass] [-p key pass] [-a key alias] 15 | This script is used to import ${pem} and ${pk8} into a Java Key Store. 16 | EOF 17 | } 18 | 19 | while [ $# -gt 0 ]; do 20 | case $1 21 | in 22 | -k) 23 | keystorepass=$2 24 | shift 2 25 | ;; 26 | -p) 27 | keypass=$2 28 | shift 2 29 | ;; 30 | -a) 31 | alias=$2 32 | shift 2 33 | ;; 34 | -h | help | -help | --help) 35 | usage 36 | exit 0 37 | esac 38 | done 39 | 40 | if [ -z ${alias} ] | [ -z ${keystorepass} ] | [ -z ${keypass} ]; then 41 | echo "${scriptname}: Missing informations..." 1>&2 42 | usage 43 | exit 1 44 | fi 45 | 46 | for f in "${pk8}" "${pem}"; do 47 | if [ ! -f "$f" ]; then 48 | echo "${scriptname}: Can't find file $f..." 1>&2 49 | exit 1 50 | fi 51 | done 52 | 53 | if [ -e ${out} ]; then 54 | mv ${out} ${out}.$(date +%s).backup 55 | fi 56 | 57 | echo openssl pkcs8 -in ${pk8} -inform DER -outform PEM -out platform.priv.pem -nocrypt 58 | openssl pkcs8 -in ${pk8} -inform DER -outform PEM -out platform.priv.pem -nocrypt 59 | 60 | echo openssl pkcs12 -export -in ${pem} -inkey platform.priv.pem -out platform.pk12 -name ${alias} -password pass:${keystorepass} 61 | openssl pkcs12 -export -in ${pem} -inkey platform.priv.pem -out platform.pk12 -name ${alias} -password pass:${keystorepass} 62 | 63 | echo keytool -J-Duser.language=en -importkeystore -destkeystore ${out} -srckeystore platform.pk12 -srcstoretype PKCS12 -deststorepass ${keystorepass} -srcstorepass ${keystorepass} 64 | keytool -J-Duser.language=en -importkeystore -destkeystore ${out} -srckeystore platform.pk12 -srcstoretype PKCS12 -deststorepass ${keystorepass} -srcstorepass ${keystorepass} 65 | 66 | echo keytool -J-Duser.language=en -keypasswd -keystore ${out} -alias ${alias} -storepass ${keystorepass} -new ${keypass} 67 | keytool -J-Duser.language=en -keypasswd -keystore ${out} -alias ${alias} -storepass ${keystorepass} -new ${keypass} 68 | 69 | rm platform.priv.pem 70 | rm platform.pk12 71 | --------------------------------------------------------------------------------