Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saveContractCertificateChain - Path to keystore #55

Closed
PySchilling opened this issue Jul 9, 2020 · 1 comment
Closed

saveContractCertificateChain - Path to keystore #55

PySchilling opened this issue Jul 9, 2020 · 1 comment

Comments

@PySchilling
Copy link

Dear Marc,

I come to one place in the code and the intention is not clear to me where to store the keystore after and updateing or installing certificates.

public static boolean saveContractCertificateChain(
		String keyStorePassword, 
		CertificateChainType contractCertChain,
		ECPrivateKey contractCertPrivateKey) {
		
KeyStore keyStore = getKeyStore(GlobalValues.EVCC_KEYSTORE_FILEPATH.toString(), keyStorePassword);

try {
	if (isPrivateKeyValid(contractCertPrivateKey, contractCertChain)) {
		keyStore.setKeyEntry(
				GlobalValues.ALIAS_CONTRACT_CERTIFICATE.toString(), 
				contractCertPrivateKey, 
				keyStorePassword.toCharArray(), 
				getCertificateChain(contractCertChain)); 
				
		// Save the keystore persistently
		try(FileOutputStream fos = new FileOutputStream("evccKeystore.jks")){
			keyStore.store(fos, 
                                  GlobalValues.PASSPHRASE_FOR_CERTIFICATES_AND_KEYS.toString().toCharArray());
		        }

Should the saved keystore be a different one or should update the exitsing one?

// Save the keystore persistently
try(FileOutputStream fos = new FileOutputStream(GlobalValues.EVCC_KEYSTORE_FILEPATH.toString())){
	keyStore.store(fos, 
        GlobalValues.PASSPHRASE_FOR_CERTIFICATES_AND_KEYS.toString().toCharArray());
}

Best regards,
Volker

@MarcMueltin
Copy link
Contributor

Hi Volker,
you're right, good point. You should use the value stated in GlobalValues. EVCC_KEYSTORE_FILEPATH. The "evccKeystore.jks" is a hard-coded value that shouldn't be there. I took care of it wit commit ce7c41d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants