Fixes for cert and keystore generation

First try to fix key, cert, and keystore generation