Analysis on Issue
======================

There are two calls made in KeytoolOpensslInteropTest.java in Line 83 and Line 
84

https://github.com/openjdk/jdk/blob/master/test/jdk/sun/security/pkcs12/KeytoolOpensslInteropTest.java#L83-L84

       a)      String opensslPath = OpensslArtifactFetcher.getOpensslPath();
       b)     generateInitialKeystores(opensslPath);


1. Call made in 
https://github.com/openjdk/jdk/blob/master/test/jdk/sun/security/pkcs12/KeytoolOpensslInteropTest.java#L83
  to get openssl path which returns "openssl"

                Execution Flow:
                ============
                
https://github.com/openjdk/jdk/blob/master/test/jdk/sun/security/pkcs12/KeytoolOpensslInteropTest.java#L83
   calls 
https://github.com/openjdk/jdk/blob/master/test/lib/jdk/test/lib/security/OpensslArtifactFetcher.java#L62
 calls 
https://github.com/openjdk/jdk/blob/master/test/lib/jdk/test/lib/security/OpensslArtifactFetcher.java#L98
 and finally returns "openssl" from 
https://github.com/openjdk/jdk/blob/master/test/lib/jdk/test/lib/security/OpensslArtifactFetcher.java#L100



2.   return value of  "openssl" is passed as argument to 
generateInitialKeystores("openssl") and same value is navigated here as well
      
https://github.com/openjdk/jdk/blob/master/test/jdk/sun/security/pkcs12/KeytoolOpensslInteropTest.java#L110
 and call made to  
 OpensslArtifactFetcher.getProviderPath("openssl") 
 
https://github.com/openjdk/jdk/blob/master/test/lib/jdk/test/lib/security/OpensslArtifactFetcher.java#L133
 ==> this is the statement where we are seeing error

 Path openSslRootPath = Path.of("openssl").getParent().getParent();

=====> Path.of("openssl").getParent() = null



Solution
==========

1. We can remove complete System Installed Library dependency and rely on 
artifacts installed through artifactory.
2. Instead of returning "openssl" from 
https://github.com/openjdk/jdk/blob/master/test/lib/jdk/test/lib/security/OpensslArtifactFetcher.java#L100
 return the absolute path of openssl.


I have opted for Solution 2. and changed the code and i encountered one more 
situation where ProviderPath doesn't contain "ossl-modules" folder at all.

e.g.

if 
https://github.com/openjdk/jdk/blob/master/test/jdk/sun/security/pkcs12/KeytoolOpensslInteropTest.java#L83
 returns absolute path "/usr/bin/openssl" then call made to get Provider Path 
here: 
https://github.com/openjdk/jdk/blob/master/test/jdk/sun/security/pkcs12/KeytoolOpensslInteropTest.java#L110
 and finally returned value is "/usr/lib/ossl-modules" from here: 
https://github.com/openjdk/jdk/blob/master/test/lib/jdk/test/lib/security/OpensslArtifactFetcher.java#L138

I noticed in some of machines /usr/lib/ossl-modules doesn't exist at all so i 
checked in my code whether this folder /usr/lib/ossl-modules exist or not.

if /usr/lib/ossl-modules exist then we can rely on system installed 
/usr/bin/openssl
if /usr/lib/ossl-modules doesn't exist then we can rely on getting openssl path 
through Artifactory.

-------------

Commit messages:
 - change tabs to spacs
 - test/lib/jdk/test/lib/security/OpensslArtifactFetcher.java
 - 8380389: Test pkcs12/KeytoolOpensslInteropTest.java#GenerateOpensslPKCS12 
fails with NPE

Changes: https://git.openjdk.org/jdk/pull/30561/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=30561&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8380389
  Stats: 74 lines in 2 files changed: 63 ins; 4 del; 7 mod
  Patch: https://git.openjdk.org/jdk/pull/30561.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/30561/head:pull/30561

PR: https://git.openjdk.org/jdk/pull/30561

Reply via email to