Fix buffer leaks during PEM to KeyStore conversion