Testing: fix Android JUnit test paths and keystore types

pull/307/head
Chris Conlon 2025-12-23 15:14:35 -07:00
parent 518632e31a
commit 9d469b5441
8 changed files with 167 additions and 115 deletions

View File

@ -104,15 +104,10 @@ after the starting Android Studio and compiling the project, but must be done
before running the app or test cases.
```
adb shell
cd sdcard
mkdir examples
mkdir examples/provider
mkdir examples/certs
exit
adb push ./examples/provider/*.bks /sdcard/examples/provider/
adb push ./examples/certs/ /sdcard/examples/
adb push ./examples/certs/intermediate/* /sdcard/examples/certs/intermediate/
adb shell mkdir -p /data/local/tmp/examples/provider
adb shell mkdir -p /data/local/tmp/examples/certs/intermediate
adb push ./examples/provider/*.bks /data/local/tmp/examples/provider/
adb push ./examples/certs/ /data/local/tmp/examples/
```
## 5. Import and Build the Example Project with Android Studio
@ -122,15 +117,11 @@ in wolfssljni/IDE/. Or, from inside Android Studio, open the `Android` project
located in the wolfssljni/IDE directory.
2) Build the project and run MainActivity from app -> java/com/example.wolfssl.
This will ask for permissions to access the certificates in the /sdcard/
directory and then print out the server certificate information on success.
This will print out the server certificate information on success.
3) OPTIONAL: The androidTests can be run after permissions have been given.
3) OPTIONAL: The androidTests can be run to verify functionality.
app->java->com.wolfssl->provider.jsse.test->WolfSSLJSSETestSuite and
app->java->com.wolfssl->test->WolfSSLTestSuite. In order to get the correct
permissions, you may need to install and run the app first, before running
the tests. Otherwise you will see EACCESS errors when trying to open
example certificate and .bks files.
app->java->com.wolfssl->test->WolfSSLTestSuite.
## Support

View File

@ -29,6 +29,9 @@ convert "client-rsa"
rm -f client-ecc.bks &> /dev/null
convert "client-ecc"
rm -f client-rsapss.bks &> /dev/null
convert "client-rsapss"
rm -f server.bks &> /dev/null
convert "server"
@ -41,6 +44,9 @@ convert "server-rsa"
rm -f server-ecc.bks &> /dev/null
convert "server-ecc"
rm -f server-rsapss.bks &> /dev/null
convert "server-rsapss"
rm -f cacerts.bks &> /dev/null
convert "cacerts"

View File

@ -536,7 +536,7 @@ public class WolfSSLKeyX509Test {
try {
/* Create empty KeyStore */
KeyStore emptyStore = KeyStore.getInstance("JKS");
KeyStore emptyStore = KeyStore.getInstance(tf.keyStoreType);
emptyStore.load(null, null);
/* Create WolfSSLKeyX509 with empty KeyStore */
@ -756,7 +756,7 @@ public class WolfSSLKeyX509Test {
"wolfjsse.X509KeyManager.disableCache", "true");
/* Create KeyManager with caching disabled */
KeyStore ks = KeyStore.getInstance("JKS");
KeyStore ks = KeyStore.getInstance(tf.keyStoreType);
java.io.FileInputStream fis =
new java.io.FileInputStream(tf.allJKS);
ks.load(fis, "wolfSSL test".toCharArray());
@ -830,7 +830,7 @@ public class WolfSSLKeyX509Test {
"wolfjsse.X509KeyManager.disableCache", "false");
/* Create KeyManager with caching enabled */
KeyStore ks = KeyStore.getInstance("JKS");
KeyStore ks = KeyStore.getInstance(tf.keyStoreType);
java.io.FileInputStream fis =
new java.io.FileInputStream(tf.allJKS);
ks.load(fis, "wolfSSL test".toCharArray());
@ -910,7 +910,7 @@ public class WolfSSLKeyX509Test {
/* Create KeyManager with default behavior
* (should be caching enabled) */
KeyStore ks = KeyStore.getInstance("JKS");
KeyStore ks = KeyStore.getInstance(tf.keyStoreType);
java.io.FileInputStream fis =
new java.io.FileInputStream(tf.allJKS);
ks.load(fis, "wolfSSL test".toCharArray());
@ -978,7 +978,7 @@ public class WolfSSLKeyX509Test {
Security.setProperty(
"wolfjsse.X509KeyManager.disableCache", trueValue);
KeyStore ks = KeyStore.getInstance("JKS");
KeyStore ks = KeyStore.getInstance(tf.keyStoreType);
java.io.FileInputStream fis =
new java.io.FileInputStream(tf.allJKS);
ks.load(fis, "wolfSSL test".toCharArray());
@ -1005,7 +1005,7 @@ public class WolfSSLKeyX509Test {
Security.setProperty(
"wolfjsse.X509KeyManager.disableCache", falseValue);
KeyStore ks = KeyStore.getInstance("JKS");
KeyStore ks = KeyStore.getInstance(tf.keyStoreType);
java.io.FileInputStream fis =
new java.io.FileInputStream(tf.allJKS);
ks.load(fis, "wolfSSL test".toCharArray());

View File

@ -1244,7 +1244,9 @@ public class WolfSSLSocketTest {
InputStream consumed = new ByteArrayInputStream(tmp);
/* create SSLSocket for server from Socket */
SSLSocket ss = (SSLSocket)((WolfSSLSocketFactory)ctx.getSocketFactory())
SSLSocket ss =
(SSLSocket)(
(WolfSSLSocketFactory)ctx.getSocketFactory())
.createSocket(server, consumed, true);
ss.startHandshake();
@ -3445,7 +3447,8 @@ public class WolfSSLSocketTest {
.createServerSocket(0);
/* Set up test arguments without explicit SNI configuration.
* With autoSNI=true, SNI should be automatically set based on hostname */
* With autoSNI=true, SNI should be automatically set based on
* hostname */
TestArgs sArgs = new TestArgs(null,
null, true,
true,
@ -3461,11 +3464,12 @@ public class WolfSSLSocketTest {
CountDownLatch sDoneLatch = new CountDownLatch(1);
CountDownLatch cDoneLatch = new CountDownLatch(1);
TestServer server = new TestServer(this.ctx, ss, sArgs, 1, sDoneLatch);
TestServer server =
new TestServer(this.ctx, ss, sArgs, 1, sDoneLatch);
server.start();
TestClient client = new TestClient(this.ctx, ss.getLocalPort(), cArgs,
cDoneLatch);
TestClient client =
new TestClient(this.ctx, ss.getLocalPort(), cArgs, cDoneLatch);
client.start();
cDoneLatch.await();
@ -3981,7 +3985,8 @@ public class WolfSSLSocketTest {
if (sock instanceof com.wolfssl.provider.jsse.WolfSSLSocket) {
try {
Field sslField =
com.wolfssl.provider.jsse.WolfSSLSocket.class.getDeclaredField("ssl");
com.wolfssl.provider.jsse
.WolfSSLSocket.class.getDeclaredField("ssl");
sslField.setAccessible(true);
sslField.set(sock, null);
@ -4086,6 +4091,15 @@ public class WolfSSLSocketTest {
String intCaCert = "examples/certs/intermediate/ca-int-ecc-cert.pem";
String int2CaCert =
"examples/certs/intermediate/ca-int2-ecc-cert.pem";
String serverEccJKS = "examples/provider/server-ecc.jks";
if (WolfSSLTestFactory.isAndroid()) {
serverIntCert = "/data/local/tmp/" + serverIntCert;
serverIntKey = "/data/local/tmp/" + serverIntKey;
intCaCert = "/data/local/tmp/" + intCaCert;
int2CaCert = "/data/local/tmp/" + int2CaCert;
serverEccJKS = "/data/local/tmp/examples/provider/server-ecc.bks";
}
X509TrustManager customTM = new X509TrustManager() {
@Override
@ -4159,7 +4173,7 @@ public class WolfSSLSocketTest {
fis.close();
/* Create KeyStore and add server cert with chain */
KeyStore serverKeyStore = KeyStore.getInstance("JKS");
KeyStore serverKeyStore = KeyStore.getInstance(tf.keyStoreType);
serverKeyStore.load(null, null);
/* Build certificate chain: server, int2 (immediate issuer), int */
@ -4170,8 +4184,8 @@ public class WolfSSLSocketTest {
/* Load existing ECC private key from server-ecc.jks, since Java
* doesn't natively support SEC1 ECC format without Bouncy Castle */
KeyStore tmpKS = KeyStore.getInstance("JKS");
fis = new FileInputStream("examples/provider/server-ecc.jks");
KeyStore tmpKS = KeyStore.getInstance(tf.keyStoreType);
fis = new FileInputStream(serverEccJKS);
tmpKS.load(fis, "wolfSSL test".toCharArray());
fis.close();

View File

@ -189,7 +189,7 @@ class WolfSSLTestFactory {
}
private boolean isAndroidFile() {
String sdc = "/sdcard/";
String sdc = "/data/local/tmp/";
File f;
if (isAndroid()) {
@ -199,10 +199,12 @@ class WolfSSLTestFactory {
clientRSA1024JKS = "examples/provider/client-rsa-1024.bks";
clientRSAJKS = "examples/provider/client-rsa.bks";
clientECCJKS = "examples/provider/client-ecc.bks";
clientRSAPSSJKS = "examples/provider/client-rsapss.bks";
serverJKS = "examples/provider/server.bks";
serverRSA1024JKS = "examples/provider/server-rsa-1024.bks";
serverRSAJKS = "examples/provider/server-rsa.bks";
serverECCJKS = "examples/provider/server-ecc.bks";
serverRSAPSSJKS = "examples/provider/server-rsapss.bks";
caJKS = "examples/provider/cacerts.bks";
caClientJKS = "examples/provider/ca-client.bks";
caServerJKS = "examples/provider/ca-server.bks";
@ -439,7 +441,8 @@ class WolfSSLTestFactory {
if (provider != null) {
ctx = SSLContext.getInstance(protocol, provider);
if (tm == null) {
localTm = createTrustManager("SunX509", clientJKS, provider);
localTm = createTrustManager("SunX509", clientJKS,
provider);
}
if (km == null) {
localKm = createKeyManager("SunX509", clientJKS, provider);
@ -1014,7 +1017,7 @@ class WolfSSLTestFactory {
/* Create new KeyStore, load in newly generated cert. Add PrivateKey
* if requested. */
KeyStore store = KeyStore.getInstance("JKS");
KeyStore store = KeyStore.getInstance(keyStoreType);
store.load(null, jksPass);
if (addPrivateKey) {

View File

@ -571,13 +571,13 @@ public class WolfSSLTrustX509Test {
String eccInt2Cert = "examples/certs/intermediate/ca-int2-ecc-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
rsaServerCert = "/sdcard/" + rsaServerCert;
rsaInt1Cert = "/sdcard/" + rsaInt1Cert;
rsaInt2Cert = "/sdcard/" + rsaInt2Cert;
rsaServerCert = "/data/local/tmp/" + rsaServerCert;
rsaInt1Cert = "/data/local/tmp/" + rsaInt1Cert;
rsaInt2Cert = "/data/local/tmp/" + rsaInt2Cert;
eccServerCert = "/sdcard/" + eccServerCert;
eccInt1Cert = "/sdcard/" + eccInt1Cert;
eccInt2Cert = "/sdcard/" + eccInt2Cert;
eccServerCert = "/data/local/tmp/" + eccServerCert;
eccInt1Cert = "/data/local/tmp/" + eccInt1Cert;
eccInt2Cert = "/data/local/tmp/" + eccInt2Cert;
}
tm = tf.createTrustManager("SunX509", tf.caJKS, provider);
@ -701,13 +701,13 @@ public class WolfSSLTrustX509Test {
"examples/certs/intermediate/ca-int2-ecc-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
rsaServerCert = "/sdcard/" + rsaServerCert;
rsaInt1CertWrong = "/sdcard/" + rsaInt1CertWrong;
rsaInt2Cert = "/sdcard/" + rsaInt2Cert;
rsaServerCert = "/data/local/tmp/" + rsaServerCert;
rsaInt1CertWrong = "/data/local/tmp/" + rsaInt1CertWrong;
rsaInt2Cert = "/data/local/tmp/" + rsaInt2Cert;
eccServerCert = "/sdcard/" + eccServerCert;
eccInt1CertWrong = "/sdcard/" + eccInt1CertWrong;
eccInt2Cert = "/sdcard/" + eccInt2Cert;
eccServerCert = "/data/local/tmp/" + eccServerCert;
eccInt1CertWrong = "/data/local/tmp/" + eccInt1CertWrong;
eccInt2Cert = "/data/local/tmp/" + eccInt2Cert;
}
tm = tf.createTrustManager("SunX509", tf.caJKS, provider);
@ -829,13 +829,13 @@ public class WolfSSLTrustX509Test {
String eccInt2Cert = "examples/certs/intermediate/ca-int2-ecc-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
rsaServerCert = "/sdcard/" + rsaServerCert;
rsaInt1Cert = "/sdcard/" + rsaInt1Cert;
rsaInt2Cert = "/sdcard/" + rsaInt2Cert;
rsaServerCert = "/data/local/tmp/" + rsaServerCert;
rsaInt1Cert = "/data/local/tmp/" + rsaInt1Cert;
rsaInt2Cert = "/data/local/tmp/" + rsaInt2Cert;
eccServerCert = "/sdcard/" + eccServerCert;
eccInt1Cert = "/sdcard/" + eccInt1Cert;
eccInt2Cert = "/sdcard/" + eccInt2Cert;
eccServerCert = "/data/local/tmp/" + eccServerCert;
eccInt1Cert = "/data/local/tmp/" + eccInt1Cert;
eccInt2Cert = "/data/local/tmp/" + eccInt2Cert;
}
tm = tf.createTrustManager("SunX509", tf.caJKS, provider);
@ -955,11 +955,11 @@ public class WolfSSLTrustX509Test {
"examples/certs/intermediate/ca-int2-ecc-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
rsaServerCert = "/sdcard/" + rsaServerCert;
rsaInt2Cert = "/sdcard/" + rsaInt2Cert;
rsaServerCert = "/data/local/tmp/" + rsaServerCert;
rsaInt2Cert = "/data/local/tmp/" + rsaInt2Cert;
eccServerCert = "/sdcard/" + eccServerCert;
eccInt2Cert = "/sdcard/" + eccInt2Cert;
eccServerCert = "/data/local/tmp/" + eccServerCert;
eccInt2Cert = "/data/local/tmp/" + eccInt2Cert;
}
tm = tf.createTrustManager("SunX509", tf.caJKS, provider);
@ -1067,13 +1067,13 @@ public class WolfSSLTrustX509Test {
"examples/certs/intermediate/ca-int2-ecc-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
rsaServerCert = "/sdcard/" + rsaServerCert;
rsaInt1Cert = "/sdcard/" + rsaInt1Cert;
rsaInt2Cert = "/sdcard/" + rsaInt2Cert;
rsaServerCert = "/data/local/tmp/" + rsaServerCert;
rsaInt1Cert = "/data/local/tmp/" + rsaInt1Cert;
rsaInt2Cert = "/data/local/tmp/" + rsaInt2Cert;
eccServerCert = "/sdcard/" + eccServerCert;
eccInt1Cert = "/sdcard/" + eccInt1Cert;
eccInt2Cert = "/sdcard/" + eccInt2Cert;
eccServerCert = "/data/local/tmp/" + eccServerCert;
eccInt1Cert = "/data/local/tmp/" + eccInt1Cert;
eccInt2Cert = "/data/local/tmp/" + eccInt2Cert;
}
tm = tf.createTrustManager("SunX509", tf.caJKS, provider);
@ -1194,13 +1194,13 @@ public class WolfSSLTrustX509Test {
String eccInt2Cert = "examples/certs/intermediate/ca-int2-ecc-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
rsaServerCert = "/sdcard/" + rsaServerCert;
rsaInt1Cert = "/sdcard/" + rsaInt1Cert;
rsaInt2Cert = "/sdcard/" + rsaInt2Cert;
rsaServerCert = "/data/local/tmp/" + rsaServerCert;
rsaInt1Cert = "/data/local/tmp/" + rsaInt1Cert;
rsaInt2Cert = "/data/local/tmp/" + rsaInt2Cert;
eccServerCert = "/sdcard/" + eccServerCert;
eccInt1Cert = "/sdcard/" + eccInt1Cert;
eccInt2Cert = "/sdcard/" + eccInt2Cert;
eccServerCert = "/data/local/tmp/" + eccServerCert;
eccInt1Cert = "/data/local/tmp/" + eccInt1Cert;
eccInt2Cert = "/data/local/tmp/" + eccInt2Cert;
}
tm = tf.createTrustManager("SunX509", tf.caJKS, provider);
@ -1354,15 +1354,15 @@ public class WolfSSLTrustX509Test {
String eccRootCert = "examples/certs/ca-ecc-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
rsaServerCert = "/sdcard/" + rsaServerCert;
rsaInt1Cert = "/sdcard/" + rsaInt1Cert;
rsaInt2Cert = "/sdcard/" + rsaInt2Cert;
rsaRootCert = "/sdcard/" + rsaRootCert;
rsaServerCert = "/data/local/tmp/" + rsaServerCert;
rsaInt1Cert = "/data/local/tmp/" + rsaInt1Cert;
rsaInt2Cert = "/data/local/tmp/" + rsaInt2Cert;
rsaRootCert = "/data/local/tmp/" + rsaRootCert;
eccServerCert = "/sdcard/" + eccServerCert;
eccInt1Cert = "/sdcard/" + eccInt1Cert;
eccInt2Cert = "/sdcard/" + eccInt2Cert;
eccRootCert = "/sdcard/" + eccRootCert;
eccServerCert = "/data/local/tmp/" + eccServerCert;
eccInt1Cert = "/data/local/tmp/" + eccInt1Cert;
eccInt2Cert = "/data/local/tmp/" + eccInt2Cert;
eccRootCert = "/data/local/tmp/" + eccRootCert;
}
tm = tf.createTrustManager("SunX509", tf.caJKS, provider);
@ -1548,6 +1548,12 @@ public class WolfSSLTrustX509Test {
String intCACert2 =
"examples/certs/intermediate/ca-int-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
rsaServerCert = "/data/local/tmp/" + rsaServerCert;
intCACert1 = "/data/local/tmp/" + intCACert1;
intCACert2 = "/data/local/tmp/" + intCACert2;
}
System.out.print("\tcheckServerTrusted() Android");
try {
@ -1573,7 +1579,7 @@ public class WolfSSLTrustX509Test {
X509Certificate[] certArray = new X509Certificate[] {
serverCert, intCert1, intCert2 };
caJKS = KeyStore.getInstance("JKS");
caJKS = KeyStore.getInstance(tf.keyStoreType);
try (FileInputStream stream = new FileInputStream(tf.caJKS)) {
caJKS.load(stream, "wolfSSL test".toCharArray());
}
@ -2423,7 +2429,7 @@ public class WolfSSLTrustX509Test {
String javaVersion = System.getProperty("java.version");
FileInputStream stream = new FileInputStream(jks);
KeyStore store = KeyStore.getInstance("JKS");
KeyStore store = KeyStore.getInstance(tf.keyStoreType);
store.load(stream, pwd.toCharArray());
stream.close();
@ -2662,9 +2668,9 @@ public class WolfSSLTrustX509Test {
X509Certificate[] certArray = new X509Certificate[3];
if (WolfSSLTestFactory.isAndroid()) {
eccServerCert = "/sdcard/" + eccServerCert;
eccInt2CaCert = "/sdcard/" + eccInt2CaCert;
eccIntCaCert = "/sdcard/" + eccIntCaCert;
eccServerCert = "/data/local/tmp/" + eccServerCert;
eccInt2CaCert = "/data/local/tmp/" + eccInt2CaCert;
eccIntCaCert = "/data/local/tmp/" + eccIntCaCert;
}
/* Load certificates in REVERSE order (CA first, server last)
@ -2776,6 +2782,14 @@ public class WolfSSLTrustX509Test {
"examples/certs/intermediate/ca-int2-cert.pem";
String intCACert2 =
"examples/certs/intermediate/ca-int-cert.pem";
String caJKSPath = "examples/provider/cacerts.jks";
if (WolfSSLTestFactory.isAndroid()) {
rsaServerCert = "/data/local/tmp/" + rsaServerCert;
intCACert1 = "/data/local/tmp/" + intCACert1;
intCACert2 = "/data/local/tmp/" + intCACert2;
caJKSPath = "/data/local/tmp/examples/provider/cacerts.bks";
}
try {
X509Certificate serverCert;
@ -2802,9 +2816,9 @@ public class WolfSSLTrustX509Test {
serverCert, intCert1, intCert2 };
/* Load cacerts.jks into KeyStore */
caJKS = KeyStore.getInstance("JKS");
caJKS = KeyStore.getInstance(tf.keyStoreType);
try (FileInputStream stream =
new FileInputStream("examples/provider/cacerts.jks")) {
new FileInputStream(caJKSPath)) {
caJKS.load(stream, "wolfSSL test".toCharArray());
}
@ -2868,11 +2882,24 @@ public class WolfSSLTrustX509Test {
System.out.print("\tcheckServerTrusted() valid OCSP");
String caJKSPath =
"examples/provider/cacerts.jks";
String ocspRootCaPath =
"examples/certs/ocsp-root-ca-cert.pem";
String intermediate1Path =
"examples/certs/ocsp-intermediate1-ca-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
caJKSPath = "/data/local/tmp/examples/provider/cacerts.bks";
ocspRootCaPath = "/data/local/tmp/" + ocspRootCaPath;
intermediate1Path = "/data/local/tmp/" + intermediate1Path;
}
try {
/* Load basic cacerts trust store */
KeyStore caJKS = KeyStore.getInstance("JKS");
KeyStore caJKS = KeyStore.getInstance(tf.keyStoreType);
try (FileInputStream stream =
new FileInputStream("examples/provider/cacerts.jks")) {
new FileInputStream(caJKSPath)) {
caJKS.load(stream, "wolfSSL test".toCharArray());
}
@ -2883,8 +2910,7 @@ public class WolfSSLTrustX509Test {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate ocspRootCa;
try (BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(
"examples/certs/ocsp-root-ca-cert.pem"))) {
new FileInputStream(ocspRootCaPath))) {
ocspRootCa = (X509Certificate)cf.generateCertificate(bis);
}
caJKS.setCertificateEntry("ocsp-root-ca", ocspRootCa);
@ -2903,8 +2929,7 @@ public class WolfSSLTrustX509Test {
* can be properly computed for OCSP matching. */
X509Certificate intermediate1Cert;
try (BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(
"examples/certs/ocsp-intermediate1-ca-cert.pem"))) {
new FileInputStream(intermediate1Path))) {
intermediate1Cert =
(X509Certificate)cf.generateCertificate(bis);
}
@ -2961,11 +2986,21 @@ public class WolfSSLTrustX509Test {
System.out.print("\tmismatched OCSP response");
String caJKSPath = "examples/provider/cacerts.jks";
String ocspRootCaPath = "examples/certs/ocsp-root-ca-cert.pem";
String serverCertPath = "examples/certs/server-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
caJKSPath = "/data/local/tmp/examples/provider/cacerts.bks";
ocspRootCaPath = "/data/local/tmp/" + ocspRootCaPath;
serverCertPath = "/data/local/tmp/" + serverCertPath;
}
try {
/* Load basic cacerts trust store */
caJKS = KeyStore.getInstance("JKS");
caJKS = KeyStore.getInstance(tf.keyStoreType);
try (FileInputStream stream =
new FileInputStream("examples/provider/cacerts.jks")) {
new FileInputStream(caJKSPath)) {
caJKS.load(stream, "wolfSSL test".toCharArray());
}
@ -2973,8 +3008,7 @@ public class WolfSSLTrustX509Test {
* OCSP response signature. */
cf = CertificateFactory.getInstance("X.509");
try (BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(
"examples/certs/ocsp-root-ca-cert.pem"))) {
new FileInputStream(ocspRootCaPath))) {
ocspRootCa = (X509Certificate)cf.generateCertificate(bis);
}
caJKS.setCertificateEntry("ocsp-root-ca", ocspRootCa);
@ -2989,7 +3023,7 @@ public class WolfSSLTrustX509Test {
* match the OCSP response (response is for serial 01 which is
* intermediate1-ca-cert.pem, not server-cert.pem). */
try (BufferedInputStream bis = new BufferedInputStream(
new FileInputStream("examples/certs/server-cert.pem"))) {
new FileInputStream(serverCertPath))) {
serverCert = (X509Certificate)cf.generateCertificate(bis);
}
@ -3614,9 +3648,9 @@ public class WolfSSLTrustX509Test {
String int2Cert = "examples/certs/intermediate/ca-int2-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
serverCert = "/sdcard/" + serverCert;
int1Cert = "/sdcard/" + int1Cert;
int2Cert = "/sdcard/" + int2Cert;
serverCert = "/data/local/tmp/" + serverCert;
int1Cert = "/data/local/tmp/" + int1Cert;
int2Cert = "/data/local/tmp/" + int2Cert;
}
/* Create TrustManager with caJKS which contains ca-cert.pem */
@ -3695,10 +3729,10 @@ public class WolfSSLTrustX509Test {
String wrongCA = "examples/certs/intermediate/ca-int-ecc-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
serverCert = "/sdcard/" + serverCert;
int1Cert = "/sdcard/" + int1Cert;
int2Cert = "/sdcard/" + int2Cert;
wrongCA = "/sdcard/" + wrongCA;
serverCert = "/data/local/tmp/" + serverCert;
int1Cert = "/data/local/tmp/" + int1Cert;
int2Cert = "/data/local/tmp/" + int2Cert;
wrongCA = "/data/local/tmp/" + wrongCA;
}
tm = tf.createTrustManager("SunX509", tf.caJKS, provider);
@ -3779,8 +3813,8 @@ public class WolfSSLTrustX509Test {
String int1Cert = "examples/certs/intermediate/ca-int-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
serverCert = "/sdcard/" + serverCert;
int1Cert = "/sdcard/" + int1Cert;
serverCert = "/data/local/tmp/" + serverCert;
int1Cert = "/data/local/tmp/" + int1Cert;
}
/* Create TrustManager with RSA CA certs */
@ -3848,9 +3882,9 @@ public class WolfSSLTrustX509Test {
String wrongCA2 = "examples/certs/intermediate/ca-int2-ecc-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
serverCert = "/sdcard/" + serverCert;
wrongCA1 = "/sdcard/" + wrongCA1;
wrongCA2 = "/sdcard/" + wrongCA2;
serverCert = "/data/local/tmp/" + serverCert;
wrongCA1 = "/data/local/tmp/" + wrongCA1;
wrongCA2 = "/data/local/tmp/" + wrongCA2;
}
/* Create TrustManager with ECC CAs only */
@ -3922,9 +3956,9 @@ public class WolfSSLTrustX509Test {
String int2Cert = "examples/certs/intermediate/ca-int2-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
serverCert = "/sdcard/" + serverCert;
int1Cert = "/sdcard/" + int1Cert;
int2Cert = "/sdcard/" + int2Cert;
serverCert = "/data/local/tmp/" + serverCert;
int1Cert = "/data/local/tmp/" + int1Cert;
int2Cert = "/data/local/tmp/" + int2Cert;
}
tm = tf.createTrustManager("SunX509", tf.caJKS, provider);
@ -3997,10 +4031,10 @@ public class WolfSSLTrustX509Test {
String wrongCA = "examples/certs/intermediate/ca-int-ecc-cert.pem";
if (WolfSSLTestFactory.isAndroid()) {
serverCert = "/sdcard/" + serverCert;
int1Cert = "/sdcard/" + int1Cert;
int2Cert = "/sdcard/" + int2Cert;
wrongCA = "/sdcard/" + wrongCA;
serverCert = "/data/local/tmp/" + serverCert;
int1Cert = "/data/local/tmp/" + int1Cert;
int2Cert = "/data/local/tmp/" + int2Cert;
wrongCA = "/data/local/tmp/" + wrongCA;
}
tm = tf.createTrustManager("SunX509", tf.caJKS, provider);

View File

@ -68,7 +68,10 @@ public class WolfSSLCertRequestTest {
}
cliKeyDer = WolfSSLTestCommon.getPath(cliKeyDer);
cliKeyPem = WolfSSLTestCommon.getPath(cliKeyPem);
cliKeyPubDer = WolfSSLTestCommon.getPath(cliKeyPubDer);
cliEccKeyDer = WolfSSLTestCommon.getPath(cliEccKeyDer);
cliEccKeyPem = WolfSSLTestCommon.getPath(cliEccKeyPem);
}
/* Internal helper method, generate test SubjectName for cert generation */

View File

@ -35,7 +35,7 @@ public class WolfSSLTestCommon {
*/
public static String getPath(String in) throws WolfSSLException {
String esc = "../../../"; /* if running from IDE directory */
String scd = "/sdcard/"; /* if running on Android */
String scd = "/data/local/tmp/"; /* if running on Android */
/* test if running from IDE directory */
File f = new File(in);
@ -44,7 +44,8 @@ public class WolfSSLTestCommon {
if (!f.exists()) {
f = new File(scd.concat(in));
if (!f.exists()) {
System.out.println("could not find files " + f.getAbsolutePath());
System.out.println("could not find files " +
f.getAbsolutePath());
throw new WolfSSLException("Unable to find test files");
}
return scd.concat(in);