# ktor

Muhammad Usman

05/27/2022, 1:57 PM
Hi, Can any one help me to get out of this problem. How can I detect where i have made a mistake , I was trying to configure SSL over Ktor . Thanks
Copy code
Exception in thread "main" Get Key failed: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
	at java.base/
	at java.base/
	at java.base/
	at io.ktor.server.netty.NettyChannelInitializer.<init>(NettyChannelInitializer.kt:55)
	at io.ktor.server.netty.NettyApplicationEngine.createBootstrap(NettyApplicationEngine.kt:145)
	at io.ktor.server.netty.NettyApplicationEngine.access$createBootstrap(NettyApplicationEngine.kt:29)
	at io.ktor.server.netty.NettyApplicationEngine$bootstraps$2.invoke(NettyApplicationEngine.kt:131)
	at io.ktor.server.netty.NettyApplicationEngine$bootstraps$2.invoke(NettyApplicationEngine.kt:130)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at io.ktor.server.netty.NettyApplicationEngine.getBootstraps$ktor_server_netty(NettyApplicationEngine.kt:130)
	at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:177)
	at org.exime.ApplicationKt.main(Application.kt:30)
	at org.exime.ApplicationKt.main(Application.kt)
Caused by: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
	at java.base/com.sun.crypto.provider.CipherCore.unpad(
	at java.base/com.sun.crypto.provider.CipherCore.fillOutputBuffer(
	at java.base/com.sun.crypto.provider.CipherCore.doFinal(
	at java.base/com.sun.crypto.provider.PKCS12PBECipherCore.implDoFinal(
	at java.base/com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndDESede.engineDoFinal(
	at java.base/javax.crypto.Cipher.doFinal(
	at java.base/$engineGetKey$0(
	at java.base/$
	at java.base/
	... 12 more

Process finished with exit code 1

Phil Richardson

05/27/2022, 5:02 PM
This error implies that your attempting to use a different password between the keystore itself, and the key inside of the store. The PKCS12 format uses the same password for both. but you can still attempt to use different ones. Getting to this point typically means you have successfully opened the keystore, but are failing to acquire the key. Update your keystore so that keystore & key passes match, or move to another keystore format like JKS which does support different passwords for store & key.