27
Views
5
Comments
[JWT] An exception "pad block corrupted" occurred in JWT Extension when using Box Connector
jwt
Service icon
Forge asset by João Almeida
Application Type
Traditional Web

When I used config.json created with a custom Box app, the following error occurred.

This error did not occur when creating a key pair before last month, but it does occur with the key pair created as of today.

config.json downloaded before last month can still be used without any errors.

Do you know the cause of the error?


[1] Unable to open private key. Validate if private key in PEM format and password is correct. 場所 OutSystems.NssJWT_Core.JwtAuth.CreateRSAParametersFromPKCS8(String keyId, String signingAlgorithm, String privateKey, String privateKeyPassword)
   場所 OutSystems.NssJWT_Core.JwtAuth.CreateAsymmetricSigningCredentialsFromPem(String keyId, String signingAlgorithm, String privateKey, String privateKeyPassword, Boolean useMachineKeystore)
   場所 OutSystems.NssJWT_Core.CssJWT_Core.CreateSigningCredentials(RCTokenSymmetricSigningCredentialsRecord symmetricCredentials, RCTokenAsymmetricSigningCredentialsRecord asymmetricCredentials)
   場所 OutSystems.NssJWT_Core.CssJWT_Core.MssCreateToken(RCTokenSymmetricSigningCredentialsRecord ssSymmetricCredentials, RCTokenAsymmetricSigningCredentialsRecord ssAsymmetricCredentials, RCTokenPayloadRecord ssPayload, Boolean ssShowDebugInformation, String& ssResultMessage, String& ssPlainToken, String& ssEncodedToken)
   場所 ssJWT.RssExtensionJWT_Core.MssCreateToken(HeContext heContext, IRecord inParamSymmetricCredentials, IRecord inParamAsymmetricCredentials, IRecord inParamPayload, Boolean inParamShowDebugInformation, String& outParamResultMessage, String& outParamPlainToken, String& outParamEncodedToken)

[2] problem creating ENCRYPTED private key: Org.BouncyCastle.Crypto.InvalidCipherTextException: pad block corrupted
   場所 Org.BouncyCastle.Crypto.Paddings.Pkcs7Padding.PadCount(Byte[] input)
   場所 Org.BouncyCastle.Crypto.Paddings.PaddedBufferedBlockCipher.DoFinal(Byte[] output, Int32 outOff)
   場所 Org.BouncyCastle.Crypto.BufferedBlockCipher.DoFinal(Byte[] input, Int32 inOff, Int32 inLen)
   場所 Org.BouncyCastle.Pkcs.PrivateKeyInfoFactory.CreatePrivateKeyInfo(Char[] passPhrase, Boolean wrongPkcs12Zero, EncryptedPrivateKeyInfo encInfo)
   場所 Org.BouncyCastle.OpenSsl.PemReader.ReadPrivateKey(PemObject pemObject)
   場所 Org.BouncyCastle.OpenSsl.PemReader.ReadPrivateKey(PemObject pemObject)
   場所 OutSystems.NssJWT_Core.JwtAuth.CreateRSAParametersFromPKCS8(String keyId, String signingAlgorithm, String privateKey, String privateKeyPassword) 

2023-12-16 19-57-03
Sanjay Kushwah

Hi @TakaIkeda,

Please check this link

Here is discussion available on the same issue you are facing.

https://www.outsystems.com/forums/discussion/78995/outsystems-nssjwt-core-jwtexception-unable-to-open-private-key/


Kind regards,

Sanjay Kushwah

UserImage.jpg
TakaIkeda

Thanks @Sanjay Kushwah
Since config.json is used as is and JSON deserialization is performed each time, it seems that the new line code is processed appropriately before entering the JWTCore extension.
I tried the above method, but there was no change in the error message.
Is there any other solution? 

2023-12-16 19-57-03
Sanjay Kushwah

can you please elaborate more this line "it seems that the new line code is processed appropriately before entering the JWTCore extension. "
what you mean? Do you want delay in Json deserialization execution ?? so your JWT core extension can be execute first ?? 


UserImage.jpg
TakaIkeda

I understand that the question you posed last time requires conversion of newline codes when manually inputting each field from the generated JSON file.
In this case, the newline codes is converted because it is input from a file through JSON deserialize.
Json deserialization execution is completed before JWT Core extension. 
I present a screenshot of the JSON file and debugging.
I decided to look at this debug. Newline codes are converted properly. 
Therefore, I think that this case is not a problem with the newline code. 

UserImage.jpg
Yasuhiro Uto

I'm having this same situation... any news about this?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.