Giter Club home page Giter Club logo

keystore-mode's Introduction

Keystore Mode

Build Status Coverage Status License: MIT MELPA

A major mode for viewing and managing (java) keystores in Emacs.

../assets/list-keystore.png?raw=true

Prerequisites

This mode uses the keytool command, which comes with OpenJDK JRE. Make sure it is installed and available on the PATH.

Installation

The package keystore-mode is available on the MELPA repository. After MELPA is setup, as explained here it can be installed with

M-x package-install RET keystore-mode RET

Or alternatively using use-package in your init.el

(use-package keystore-mode)

Usage

There are several ways to open a buffer in keystore-mode.

Creating a new keystore

Create a new keystore with M-x keystore-genkeypair. This command will prompt the user for certificate parameters. After the key and the certificate are generated, the keystore is displayed in a new buffer with keystore-mode.

Or create a new keystore with M-x keystore-genseckey. This command will prompt the user for key parameters. After the key is generated, the key is displayed in a new buffer with keystore-mode.

Alternatively you can create an empty keystore with M-x keystore-empty. This command will prompt for a keystore filename and a keystore password (twice), and create that keystore. By default it will not overwrite existing files, this behaviour can be overridden with the universal argument, i.e. C-u M-x keystore-empty.

Opening an existing keystore

Open an existing keystore with M-x keystore-visit. After selecting the keystore file, you’re asked to enter the keystore password. This password is stored in a buffer local variable. It is recommended to kill the buffer (bound to q) directly after you’re done with the keystore.

Backups

Following emacs’ philosophy, a backup of the keystore is created before any command is executed that modifies the keystore. In contrast to normal buffers, this is being done by the backup-buffer function because all keystore modifications are performed on the file system by the keytool command, and not on the contents of the buffer itself.

As a consequence the backups will be created following customizations of the backup group, however hooks like before-save-hook and after-save-hook are not executed. So customizations based on those hooks (f.e. like proposed on the wiki) will not have any effect here.

Key bindings

The mode defines the following keybindings:

KeyCommandDescription
dkeystore-toggle-mark-deleteMark or unmark entry under point for deletion
xkeystore-executeExecute marked changes (deletes) guarded by y-or-n-p
ckeystore-changealiasChange alias for entry under point using keytool -changealias
ekeystore-exportcertExport certificate for entry under point using keytool -exportcert
Gpkeystore-genkeypair-listGenerate a new key pair with self-signed certifiate using keytool -genkeypair
Gskeystore-genseckey-listGenerate a new secure key using keytool -genseckey
Pkeystore-printcertCreate new buffer with certificate defailt using keytool -printcert
ibkeystore-importcert-bufferImport certificate from buffer using keytool -importcert
ifkeystore-importcert-fileImport certificate from file using keytool -importcert
Ikeystore-importkeystoreImport a full keystore from file usig keytool -importkeystore
lkeystore-listOpen new buffer with output of keytool -list
rkeystore-list-rfcOpen new buffer with output of keytool -list -rfc
Rkeystore-revisitCompletely reload current keystore, to refresh customizations
skeystore-certreqGenerate a CSR file for key under point with keytool -certreq
Skeystore-gencertGenerate a certificate for CSR file with keytool -gencert
vkeystore-list-verboseOpen new buffer with output of keytool -list -v
qkill-this-bufferKill the buffer and any local variables

The keystore-list-rfc command opens a buffer where the certificates are folded (using origami.el). The folding can be toggled with the <TAB> key.

Customization

keystore-mode is customizable in the customization group keystore-mode (M-x customize-group RET keystore-mode RET). For example the following configuration shows SHA1 fingerprint instead of SHA256 and adds the validity dates of certificates.

(custom-set-variables
 '(keystore-display-columns
   '(("fingerprint (SHA1)" 40 nil)
     ("type" 20 t)
     ("alias" 64 t)
     ("Valid from" 32 nil)
     ("Valid until" 0 nil))))

To apply new customizations to existing keystore buffers, use keystore-revisit.

Troubleshooting

Unable to operate on aliases containing (non-ascii) unicode characters.

Make sure that you’ve configured locales correctly on your system. For example for UTF-8:

sudo update-locale LC_ALL=en_US.UTF-8

Future ideas/TODOs

  • [ ] Add support for openssl and make it a more generic/versatile keystore/certificate management tool.
  • [X] Backup the keystore before making changes to it.
  • [X] Detect incorrect entered keystore passwords, and re-prompt the user.
  • [ ] Currently generated keys get the keystore password, allow setting other passwords on keys.
  • [X] Use call-process or process-file to invoke keytool
  • [ ] Make keystore-mode play nice with TRAMP, to allow managing remote keystores.

Contributing

I am open to any kind of feedback via issues.

For bug-fixes and/or new features, open a pull-request. Please create or update testcases for your changes, and make sure to add yourself to the AUTHORS file.

Development

This repository provides a Caskfile for development purposes.

Tests are created with ecukes. The testsuite can be run with the following command:

cask exec ecukes

keystore-mode's People

Contributors

peterpaul avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.