2

While calling from one module to another I am facing hash mismatch issue. Hash is first generated in caller module using request parameters and sent to called module in Request Header. Called module then generates hash from request and validates if newly generated hash matches or not. While verifying in test environment it works fine but still facing issue in prod environment. I am using RestTemplate for HTTP call and HMAC with SHA256 for hashing. I have also tried adding httpMessageConverter for unicode support but still facing the issue.

  1. Hash matches if unicode value is removed.

  2. Hash matches in test environment but fails in prod even if all the configurations are same like java version, tomcat version and so on.

  3. Tried adding message converters but still facing the isssue.

    RestTemplate restTemplate = new RestTemplate();
     restTemplate.getMessageConverters()
             .add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8)); 
    
  • Can you paste a screenshot or exact error trace ?? – rootExplorr Aug 09 '22 at 09:53
  • I have custom validation to validate if signature sent from caller module in header differ from that generated hash from request in called module then throw RuntimeException. In prod environment, every case where unicode is present in request application throws this exception. – Sanish Maharjan Aug 09 '22 at 10:03
  • So you are matching whether the hash the caller sends and the hash generated for request match or not. If this works on test environment, then it seems that its about incorrect values of environment variables configured in your prod env. Check those. – rootExplorr Aug 09 '22 at 10:07
  • Yes exactly. Problem is that I am not able to replicate in local or in test environment. – Sanish Maharjan Aug 09 '22 at 10:08
  • Does ```System.out.println(System.getProperty("file.encoding"));``` differ between prod and dev? – g00se Aug 09 '22 at 11:28
  • Its same for both environment. – Sanish Maharjan Aug 10 '22 at 11:22

0 Answers0