-->

Java Keystore.getKey() slow while Key store size I

2019-02-27 18:29发布

问题:

I am using java key store to store and retrieve encryption key.It works faster while my key store size is small. But once my key store size is increased than key store operation goes slow.

I am working on linux platform, Java version Jdk_1.8. and safenet as provider.

回答1:

I have been facing the same issue related to execution speed varies with different operation system platform.

Jvm loads key store in memory. And its having hashtable collection as internal storage.

Hashtable is synchronized.

Whenever you perform get operation from key store, than it will return it from in-memory key store not from physical keystore. You can confirm it by using ("top" - %wa section) command in linux base OS.

Key store is using hashtable and it is the root cause behind performance decriment.

I have solved this issue by loading all keys from keystore into ConcurrentHashMap while initializing the project. and later on, All the read operation will be performed from MAP instead of keystore. And make sure that all write operation will be perform on both keystore and MAP.



回答2:

We have faced this issue when we were using safenet jar file as a key store provider, when I removed safenet as a provider & used default providers of java then I didn't face any performance related issue.