https://kotlinlang.org logo
#ktor
Title
# ktor
m

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" java.security.UnrecoverableKeyException: Get Key failed: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
	at java.base/sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:457)
	at java.base/sun.security.util.KeyStoreDelegator.engineGetKey(KeyStoreDelegator.java:90)
	at java.base/java.security.KeyStore.getKey(KeyStore.java:1050)
	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(CipherCore.java:977)
	at java.base/com.sun.crypto.provider.CipherCore.fillOutputBuffer(CipherCore.java:1058)
	at java.base/com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:855)
	at java.base/com.sun.crypto.provider.PKCS12PBECipherCore.implDoFinal(PKCS12PBECipherCore.java:408)
	at java.base/com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndDESede.engineDoFinal(PKCS12PBECipherCore.java:440)
	at java.base/javax.crypto.Cipher.doFinal(Cipher.java:2207)
	at java.base/sun.security.pkcs12.PKCS12KeyStore.lambda$engineGetKey$0(PKCS12KeyStore.java:401)
	at java.base/sun.security.pkcs12.PKCS12KeyStore$RetryWithZero.run(PKCS12KeyStore.java:291)
	at java.base/sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:395)
	... 12 more

Process finished with exit code 1
p

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.
30 Views