Path: blob/master/test/jdk/sun/security/pkcs11/PKCS11Test.java
41152 views
/*1* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223// common infrastructure for SunPKCS11 tests2425import java.io.ByteArrayOutputStream;26import java.io.File;27import java.io.IOException;28import java.io.InputStream;29import java.io.StringReader;30import java.nio.charset.StandardCharsets;31import java.nio.file.Files;32import java.nio.file.Path;33import java.nio.file.Paths;34import java.nio.file.StandardCopyOption;35import java.security.AlgorithmParameters;36import java.security.InvalidAlgorithmParameterException;37import java.security.KeyPairGenerator;38import java.security.NoSuchProviderException;39import java.security.Policy;40import java.security.Provider;41import java.security.ProviderException;42import java.security.Security;43import java.security.spec.ECGenParameterSpec;44import java.security.spec.ECParameterSpec;45import java.util.ArrayList;46import java.util.Arrays;47import java.util.HashMap;48import java.util.Iterator;49import java.util.List;50import java.util.Map;51import java.util.Optional;52import java.util.Properties;53import java.util.ServiceConfigurationError;54import java.util.ServiceLoader;55import java.util.Set;5657import jdk.test.lib.artifacts.Artifact;58import jdk.test.lib.artifacts.ArtifactResolver;59import jdk.test.lib.artifacts.ArtifactResolverException;6061public abstract class PKCS11Test {6263private boolean enableSM = false;6465static final Properties props = System.getProperties();6667static final String PKCS11 = "PKCS11";6869// directory of the test source70static final String BASE = System.getProperty("test.src", ".");7172static final String TEST_CLASSES = System.getProperty("test.classes", ".");7374static final char SEP = File.separatorChar;7576private static final String DEFAULT_POLICY =77BASE + SEP + ".." + SEP + "policy";7879// directory corresponding to BASE in the /closed hierarchy80static final String CLOSED_BASE;8182static {83// hack84String absBase = new File(BASE).getAbsolutePath();85int k = absBase.indexOf(SEP + "test" + SEP + "jdk" + SEP);86if (k < 0) k = 0;87String p1 = absBase.substring(0, k);88String p2 = absBase.substring(k);89CLOSED_BASE = p1 + "/../closed" + p2;9091// set it as a system property to make it available in policy file92System.setProperty("closed.base", CLOSED_BASE);93}9495// NSS version info96public static enum ECCState { None, Basic, Extended };97static double nss_version = -1;98static ECCState nss_ecc_status = ECCState.Basic;99100// The NSS library we need to search for in getNSSLibDir()101// Default is "libsoftokn3.so", listed as "softokn3"102// The other is "libnss3.so", listed as "nss3".103static String nss_library = "softokn3";104105// NSS versions of each library. It is simplier to keep nss_version106// for quick checking for generic testing than many if-else statements.107static double softoken3_version = -1;108static double nss3_version = -1;109static Provider pkcs11 = newPKCS11Provider();110111public static Provider newPKCS11Provider() {112ServiceLoader sl = ServiceLoader.load(java.security.Provider.class);113Iterator<Provider> iter = sl.iterator();114Provider p = null;115boolean found = false;116while (iter.hasNext()) {117try {118p = iter.next();119if (p.getName().equals("SunPKCS11")) {120found = true;121break;122}123} catch (Exception | ServiceConfigurationError e) {124// ignore and move on to the next one125}126}127// Nothing found through ServiceLoader; fall back to reflection128if (!found) {129try {130Class clazz = Class.forName("sun.security.pkcs11.SunPKCS11");131p = (Provider) clazz.newInstance();132} catch (Exception ex) {133ex.printStackTrace();134}135}136return p;137}138139// Return the static test SunPKCS11 provider configured with the specified config file140static Provider getSunPKCS11(String config) throws Exception {141return getSunPKCS11(config, pkcs11);142}143144// Return the Provider p configured with the specified config file145static Provider getSunPKCS11(String config, Provider p) throws Exception {146if (p == null) {147throw new NoSuchProviderException("No PKCS11 provider available");148}149return p.configure(config);150}151152public abstract void main(Provider p) throws Exception;153154protected boolean skipTest(Provider p) {155return false;156}157158private void premain(Provider p) throws Exception {159if (skipTest(p)) {160return;161}162163// set a security manager and policy before a test case runs,164// and disable them after the test case finished165try {166if (enableSM) {167System.setSecurityManager(new SecurityManager());168}169long start = System.currentTimeMillis();170System.out.printf(171"Running test with provider %s (security manager %s) ...%n",172p.getName(), enableSM ? "enabled" : "disabled");173main(p);174long stop = System.currentTimeMillis();175System.out.println("Completed test with provider " + p.getName() +176" (" + (stop - start) + " ms).");177} finally {178if (enableSM) {179System.setSecurityManager(null);180}181}182}183184public static void main(PKCS11Test test) throws Exception {185main(test, null);186}187188public static void main(PKCS11Test test, String[] args) throws Exception {189if (args != null) {190if (args.length > 0) {191if ("sm".equals(args[0])) {192test.enableSM = true;193} else {194throw new RuntimeException("Unknown Command, use 'sm' as "195+ "first argument to enable security manager");196}197}198if (test.enableSM) {199System.setProperty("java.security.policy",200(args.length > 1) ? BASE + SEP + args[1]201: DEFAULT_POLICY);202}203}204205Provider[] oldProviders = Security.getProviders();206try {207System.out.println("Beginning test run " + test.getClass().getName() + "...");208testDefault(test);209testNSS(test);210testDeimos(test);211} finally {212// NOTE: Do not place a 'return' in any finally block213// as it will suppress exceptions and hide test failures.214Provider[] newProviders = Security.getProviders();215boolean found = true;216// Do not restore providers if nothing changed. This is especailly217// useful for ./Provider/Login.sh, where a SecurityManager exists.218if (oldProviders.length == newProviders.length) {219found = false;220for (int i = 0; i<oldProviders.length; i++) {221if (oldProviders[i] != newProviders[i]) {222found = true;223break;224}225}226}227if (found) {228for (Provider p: newProviders) {229Security.removeProvider(p.getName());230}231for (Provider p: oldProviders) {232Security.addProvider(p);233}234}235}236}237238public static void testDeimos(PKCS11Test test) throws Exception {239if (new File("/opt/SUNWconn/lib/libpkcs11.so").isFile() == false ||240"true".equals(System.getProperty("NO_DEIMOS"))) {241return;242}243String base = getBase();244String p11config = base + SEP + "nss" + SEP + "p11-deimos.txt";245Provider p = getSunPKCS11(p11config);246test.premain(p);247}248249public static void testDefault(PKCS11Test test) throws Exception {250// run test for default configured PKCS11 providers (if any)251252if ("true".equals(System.getProperty("NO_DEFAULT"))) {253return;254}255256Provider[] providers = Security.getProviders();257for (int i = 0; i < providers.length; i++) {258Provider p = providers[i];259if (p.getName().startsWith("SunPKCS11-")) {260test.premain(p);261}262}263}264265private static String PKCS11_BASE;266static {267try {268PKCS11_BASE = getBase();269} catch (Exception e) {270// ignore271}272}273274private final static String PKCS11_REL_PATH = "sun/security/pkcs11";275276public static String getBase() throws Exception {277if (PKCS11_BASE != null) {278return PKCS11_BASE;279}280File cwd = new File(System.getProperty("test.src", ".")).getCanonicalFile();281while (true) {282File file = new File(cwd, "TEST.ROOT");283if (file.isFile()) {284break;285}286cwd = cwd.getParentFile();287if (cwd == null) {288throw new Exception("Test root directory not found");289}290}291PKCS11_BASE = new File(cwd, PKCS11_REL_PATH.replace('/', SEP)).getAbsolutePath();292return PKCS11_BASE;293}294295public static String getNSSLibDir() throws Exception {296return getNSSLibDir(nss_library);297}298299static String getNSSLibDir(String library) throws Exception {300Path libPath = getNSSLibPath(library);301if (libPath == null) {302return null;303}304305String libDir = String.valueOf(libPath.getParent()) + File.separatorChar;306System.out.println("nssLibDir: " + libDir);307System.setProperty("pkcs11test.nss.libdir", libDir);308return libDir;309}310311private static Path getNSSLibPath() throws Exception {312return getNSSLibPath(nss_library);313}314315static Path getNSSLibPath(String library) throws Exception {316String osid = getOsId();317String[] nssLibDirs = getNssLibPaths(osid);318if (nssLibDirs == null) {319System.out.println("Warning: unsupported OS: " + osid320+ ", please initialize NSS librarys location firstly, skipping test");321return null;322}323if (nssLibDirs.length == 0) {324System.out.println("Warning: NSS not supported on this platform, skipping test");325return null;326}327328Path nssLibPath = null;329for (String dir : nssLibDirs) {330Path libPath = Paths.get(dir).resolve(System.mapLibraryName(library));331if (Files.exists(libPath)) {332nssLibPath = libPath;333break;334}335}336if (nssLibPath == null) {337System.out.println("Warning: can't find NSS librarys on this machine, skipping test");338return null;339}340return nssLibPath;341}342343private static String getOsId() {344String osName = props.getProperty("os.name");345if (osName.startsWith("Win")) {346osName = "Windows";347} else if (osName.equals("Mac OS X")) {348osName = "MacOSX";349}350String osid = osName + "-" + props.getProperty("os.arch") + "-"351+ props.getProperty("sun.arch.data.model");352return osid;353}354355static boolean isBadNSSVersion(Provider p) {356double nssVersion = getNSSVersion();357if (isNSS(p) && nssVersion >= 3.11 && nssVersion < 3.12) {358System.out.println("NSS 3.11 has a DER issue that recent " +359"version do not, skipping");360return true;361}362return false;363}364365protected static void safeReload(String lib) throws Exception {366try {367System.load(lib);368} catch (UnsatisfiedLinkError e) {369if (e.getMessage().contains("already loaded")) {370return;371}372}373}374375static boolean loadNSPR(String libdir) throws Exception {376// load NSS softoken dependencies in advance to avoid resolver issues377String dir = libdir.endsWith(File.separator)378? libdir379: libdir + File.separator;380safeReload(dir + System.mapLibraryName("nspr4"));381safeReload(dir + System.mapLibraryName("plc4"));382safeReload(dir + System.mapLibraryName("plds4"));383safeReload(dir + System.mapLibraryName("sqlite3"));384safeReload(dir + System.mapLibraryName("nssutil3"));385return true;386}387388// Check the provider being used is NSS389public static boolean isNSS(Provider p) {390return p.getName().toUpperCase().equals("SUNPKCS11-NSS");391}392393static double getNSSVersion() {394if (nss_version == -1)395getNSSInfo();396return nss_version;397}398399static ECCState getNSSECC() {400if (nss_version == -1)401getNSSInfo();402return nss_ecc_status;403}404405public static double getLibsoftokn3Version() {406if (softoken3_version == -1)407return getNSSInfo("softokn3");408return softoken3_version;409}410411public static double getLibnss3Version() {412if (nss3_version == -1)413return getNSSInfo("nss3");414return nss3_version;415}416417/* Read the library to find out the verison */418static void getNSSInfo() {419getNSSInfo(nss_library);420}421422// Try to parse the version for the specified library.423// Assuming the library contains either of the following patterns:424// $Header: NSS <version>425// Version: NSS <version>426// Here, <version> stands for NSS version.427static double getNSSInfo(String library) {428// look for two types of headers in NSS libraries429String nssHeader1 = "$Header: NSS";430String nssHeader2 = "Version: NSS";431boolean found = false;432String s = null;433int i = 0;434Path libfile = null;435436if (library.compareTo("softokn3") == 0 && softoken3_version > -1)437return softoken3_version;438if (library.compareTo("nss3") == 0 && nss3_version > -1)439return nss3_version;440441try {442libfile = getNSSLibPath();443if (libfile == null) {444return 0.0;445}446try (InputStream is = Files.newInputStream(libfile)) {447byte[] data = new byte[1000];448int read = 0;449450while (is.available() > 0) {451if (read == 0) {452read = is.read(data, 0, 1000);453} else {454// Prepend last 100 bytes in case the header was split455// between the reads.456System.arraycopy(data, 900, data, 0, 100);457read = 100 + is.read(data, 100, 900);458}459460s = new String(data, 0, read, StandardCharsets.US_ASCII);461i = s.indexOf(nssHeader1);462if (i > 0 || (i = s.indexOf(nssHeader2)) > 0) {463found = true;464// If the nssHeader is before 920 we can break, otherwise465// we may not have the whole header so do another read. If466// no bytes are in the stream, that is ok, found is true.467if (i < 920) {468break;469}470}471}472}473} catch (Exception e) {474e.printStackTrace();475}476477if (!found) {478System.out.println("lib" + library +479" version not found, set to 0.0: " + libfile);480nss_version = 0.0;481return nss_version;482}483484// the index after whitespace after nssHeader485int afterheader = s.indexOf("NSS", i) + 4;486String version = String.valueOf(s.charAt(afterheader));487for (char c = s.charAt(++afterheader);488c == '.' || (c >= '0' && c <= '9');489c = s.charAt(++afterheader)) {490version += c;491}492493// If a "dot dot" release, strip the extra dots for double parsing494String[] dot = version.split("\\.");495if (dot.length > 2) {496version = dot[0]+"."+dot[1];497for (int j = 2; dot.length > j; j++) {498version += dot[j];499}500}501502// Convert to double for easier version value checking503try {504nss_version = Double.parseDouble(version);505} catch (NumberFormatException e) {506System.out.println("===== Content start =====");507System.out.println(s);508System.out.println("===== Content end =====");509System.out.println("Failed to parse lib" + library +510" version. Set to 0.0");511e.printStackTrace();512}513514System.out.print("lib" + library + " version = "+version+". ");515516// Check for ECC517if (s.indexOf("Basic") > 0) {518nss_ecc_status = ECCState.Basic;519System.out.println("ECC Basic.");520} else if (s.indexOf("Extended") > 0) {521nss_ecc_status = ECCState.Extended;522System.out.println("ECC Extended.");523} else {524System.out.println("ECC None.");525}526527if (library.compareTo("softokn3") == 0) {528softoken3_version = nss_version;529} else if (library.compareTo("nss3") == 0) {530nss3_version = nss_version;531}532533return nss_version;534}535536// Used to set the nss_library file to search for libsoftokn3.so537public static void useNSS() {538nss_library = "nss3";539}540541// Run NSS testing on a Provider p configured with test nss config542public static void testNSS(PKCS11Test test) throws Exception {543String nssConfig = getNssConfig();544if (nssConfig == null) {545// issue loading libraries546return;547}548Provider p = getSunPKCS11(nssConfig);549test.premain(p);550}551552public static String getNssConfig() throws Exception {553String libdir = getNSSLibDir();554if (libdir == null) {555return null;556}557558if (loadNSPR(libdir) == false) {559return null;560}561562String base = getBase();563564String libfile = libdir + System.mapLibraryName(nss_library);565566String customDBdir = System.getProperty("CUSTOM_DB_DIR");567String dbdir = (customDBdir != null) ?568customDBdir :569base + SEP + "nss" + SEP + "db";570// NSS always wants forward slashes for the config path571dbdir = dbdir.replace('\\', '/');572573String customConfig = System.getProperty("CUSTOM_P11_CONFIG");574String customConfigName = System.getProperty("CUSTOM_P11_CONFIG_NAME", "p11-nss.txt");575System.setProperty("pkcs11test.nss.lib", libfile);576System.setProperty("pkcs11test.nss.db", dbdir);577return (customConfig != null) ?578customConfig :579base + SEP + "nss" + SEP + customConfigName;580}581582// Generate a vector of supported elliptic curves of a given provider583static List<ECParameterSpec> getKnownCurves(Provider p) throws Exception {584int index;585int begin;586int end;587String curve;588589List<ECParameterSpec> results = new ArrayList<>();590// Get Curves to test from SunEC.591String kcProp = Security.getProvider("SunEC").592getProperty("AlgorithmParameters.EC SupportedCurves");593594if (kcProp == null) {595throw new RuntimeException(596"\"AlgorithmParameters.EC SupportedCurves property\" not found");597}598599System.out.println("Finding supported curves using list from SunEC\n");600index = 0;601for (;;) {602// Each set of curve names is enclosed with brackets.603begin = kcProp.indexOf('[', index);604end = kcProp.indexOf(']', index);605if (begin == -1 || end == -1) {606break;607}608609/*610* Each name is separated by a comma.611* Just get the first name in the set.612*/613index = end + 1;614begin++;615end = kcProp.indexOf(',', begin);616if (end == -1) {617// Only one name in the set.618end = index -1;619}620621curve = kcProp.substring(begin, end);622getSupportedECParameterSpec(curve, p)623.ifPresent(spec -> results.add(spec));624}625626if (results.size() == 0) {627throw new RuntimeException("No supported EC curves found");628}629630return results;631}632633static Optional<ECParameterSpec> getSupportedECParameterSpec(String curve,634Provider p) throws Exception {635ECParameterSpec e = getECParameterSpec(p, curve);636System.out.print("\t "+ curve + ": ");637try {638KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", p);639kpg.initialize(e);640kpg.generateKeyPair();641System.out.println("Supported");642return Optional.of(e);643} catch (ProviderException ex) {644System.out.println("Unsupported: PKCS11: " +645ex.getCause().getMessage());646return Optional.empty();647} catch (InvalidAlgorithmParameterException ex) {648System.out.println("Unsupported: Key Length: " +649ex.getMessage());650return Optional.empty();651}652}653654private static ECParameterSpec getECParameterSpec(Provider p, String name)655throws Exception {656657AlgorithmParameters parameters =658AlgorithmParameters.getInstance("EC", p);659660parameters.init(new ECGenParameterSpec(name));661662return parameters.getParameterSpec(ECParameterSpec.class);663}664665// Check support for a curve with a provided Vector of EC support666boolean checkSupport(List<ECParameterSpec> supportedEC,667ECParameterSpec curve) {668for (ECParameterSpec ec: supportedEC) {669if (ec.equals(curve)) {670return true;671}672}673return false;674}675676private static Map<String,String[]> osMap;677678// Location of the NSS libraries on each supported platform679private static Map<String, String[]> getOsMap() {680if (osMap != null) {681return osMap;682}683684osMap = new HashMap<>();685osMap.put("Linux-i386-32", new String[] {686"/usr/lib/i386-linux-gnu/",687"/usr/lib32/",688"/usr/lib/" });689osMap.put("Linux-amd64-64", new String[] {690"/usr/lib/x86_64-linux-gnu/",691"/usr/lib/x86_64-linux-gnu/nss/",692"/usr/lib64/" });693osMap.put("Linux-ppc64-64", new String[] { "/usr/lib64/" });694osMap.put("Linux-ppc64le-64", new String[] { "/usr/lib64/" });695osMap.put("Linux-s390x-64", new String[] { "/usr/lib64/" });696osMap.put("Windows-x86-32", new String[] {});697osMap.put("Windows-amd64-64", new String[] {});698osMap.put("MacOSX-x86_64-64", new String[] {});699osMap.put("Linux-arm-32", new String[] {700"/usr/lib/arm-linux-gnueabi/nss/",701"/usr/lib/arm-linux-gnueabihf/nss/" });702osMap.put("Linux-aarch64-64", new String[] {703"/usr/lib/aarch64-linux-gnu/",704"/usr/lib/aarch64-linux-gnu/nss/",705"/usr/lib64/" });706return osMap;707}708709private static String[] getNssLibPaths(String osId) {710String[] preferablePaths = getPreferableNssLibPaths(osId);711if (preferablePaths.length != 0) {712return preferablePaths;713} else {714return getOsMap().get(osId);715}716}717718private static String[] getPreferableNssLibPaths(String osId) {719List<String> nssLibPaths = new ArrayList<>();720721String customNssLibPaths = System.getProperty("test.nss.lib.paths");722if (customNssLibPaths == null) {723// If custom local NSS lib path is not provided,724// try to download NSS libs from artifactory725String path = fetchNssLib(osId);726if (path != null) {727nssLibPaths.add(path);728}729} else {730String[] paths = customNssLibPaths.split(",");731for (String path : paths) {732if (!path.endsWith(File.separator)) {733nssLibPaths.add(path + File.separator);734} else {735nssLibPaths.add(path);736}737}738}739740return nssLibPaths.toArray(new String[nssLibPaths.size()]);741}742743private final static char[] hexDigits = "0123456789abcdef".toCharArray();744745public static String toString(byte[] b) {746if (b == null) {747return "(null)";748}749StringBuilder sb = new StringBuilder(b.length * 3);750for (int i = 0; i < b.length; i++) {751int k = b[i] & 0xff;752if (i != 0) {753sb.append(':');754}755sb.append(hexDigits[k >>> 4]);756sb.append(hexDigits[k & 0xf]);757}758return sb.toString();759}760761public static byte[] parse(String s) {762if (s.equals("(null)")) {763return null;764}765try {766int n = s.length();767ByteArrayOutputStream out = new ByteArrayOutputStream(n / 3);768StringReader r = new StringReader(s);769while (true) {770int b1 = nextNibble(r);771if (b1 < 0) {772break;773}774int b2 = nextNibble(r);775if (b2 < 0) {776throw new RuntimeException("Invalid string " + s);777}778int b = (b1 << 4) | b2;779out.write(b);780}781return out.toByteArray();782} catch (IOException e) {783throw new RuntimeException(e);784}785}786787private static int nextNibble(StringReader r) throws IOException {788while (true) {789int ch = r.read();790if (ch == -1) {791return -1;792} else if ((ch >= '0') && (ch <= '9')) {793return ch - '0';794} else if ((ch >= 'a') && (ch <= 'f')) {795return ch - 'a' + 10;796} else if ((ch >= 'A') && (ch <= 'F')) {797return ch - 'A' + 10;798}799}800}801802<T> T[] concat(T[] a, T[] b) {803if ((b == null) || (b.length == 0)) {804return a;805}806T[] r = Arrays.copyOf(a, a.length + b.length);807System.arraycopy(b, 0, r, a.length, b.length);808return r;809}810811/**812* Returns supported algorithms of specified type.813*/814static List<String> getSupportedAlgorithms(String type, String alg,815Provider p) {816// prepare a list of supported algorithms817List<String> algorithms = new ArrayList<>();818Set<Provider.Service> services = p.getServices();819for (Provider.Service service : services) {820if (service.getType().equals(type)821&& service.getAlgorithm().startsWith(alg)) {822algorithms.add(service.getAlgorithm());823}824}825return algorithms;826}827828static byte[] generateData(int length) {829byte data[] = new byte[length];830for (int i=0; i<data.length; i++) {831data[i] = (byte) (i % 256);832}833return data;834}835836private static String fetchNssLib(String osId) {837switch (osId) {838case "Windows-x86-32":839return fetchNssLib(WINDOWS_X86.class);840841case "Windows-amd64-64":842return fetchNssLib(WINDOWS_X64.class);843844case "MacOSX-x86_64-64":845return fetchNssLib(MACOSX_X64.class);846847case "Linux-amd64-64":848return fetchNssLib(LINUX_X64.class);849850default:851return null;852}853}854855private static String fetchNssLib(Class<?> clazz) {856String path = null;857try {858path = ArtifactResolver.resolve(clazz).entrySet().stream()859.findAny().get().getValue() + File.separator + "nsslib"860+ File.separator;861} catch (ArtifactResolverException e) {862Throwable cause = e.getCause();863if (cause == null) {864System.out.println("Cannot resolve artifact, "865+ "please check if JIB jar is present in classpath.");866} else {867throw new RuntimeException("Fetch artifact failed: " + clazz868+ "\nPlease make sure the artifact is available.", e);869}870}871Policy.setPolicy(null); // Clear the policy created by JIB if any872return path;873}874875protected void setCommonSystemProps() {876System.setProperty("java.security.debug", "true");877System.setProperty("NO_DEIMOS", "true");878System.setProperty("NO_DEFAULT", "true");879System.setProperty("CUSTOM_DB_DIR", TEST_CLASSES);880}881882protected void copyNssCertKeyToClassesDir() throws IOException {883Path dbPath = Path.of(BASE).getParent().resolve("nss").resolve("db");884copyNssCertKeyToClassesDir(dbPath);885}886887protected void copyNssCertKeyToClassesDir(Path dbPath) throws IOException {888Path destinationPath = Path.of(TEST_CLASSES);889String keyDbFile = "key3.db";890String certDbFile = "cert8.db";891892Files.copy(dbPath.resolve(certDbFile),893destinationPath.resolve(certDbFile),894StandardCopyOption.REPLACE_EXISTING);895Files.copy(dbPath.resolve(keyDbFile),896destinationPath.resolve(keyDbFile),897StandardCopyOption.REPLACE_EXISTING);898}899900@Artifact(901organization = "jpg.tests.jdk.nsslib",902name = "nsslib-windows_x64",903revision = "3.46-VS2017",904extension = "zip")905private static class WINDOWS_X64 { }906907@Artifact(908organization = "jpg.tests.jdk.nsslib",909name = "nsslib-windows_x86",910revision = "3.46-VS2017",911extension = "zip")912private static class WINDOWS_X86 { }913914@Artifact(915organization = "jpg.tests.jdk.nsslib",916name = "nsslib-macosx_x64",917revision = "3.46",918extension = "zip")919private static class MACOSX_X64 { }920921@Artifact(922organization = "jpg.tests.jdk.nsslib",923name = "nsslib-linux_x64",924revision = "3.46",925extension = "zip")926private static class LINUX_X64 { }927}928929930