update OCSP support to match CyaSSL 2.9.4

pull/2/head
Chris Conlon 2014-04-15 15:43:28 -06:00
parent ffa207e4d2
commit 359483fab7
8 changed files with 75 additions and 33 deletions

View File

@ -240,13 +240,12 @@ public class Client {
/* set OCSP options, override URL */
if (useOcsp == 1) {
long ocspOptions = WolfSSL.CYASSL_OCSP_ENABLE |
WolfSSL.CYASSL_OCSP_NO_NONCE;
ret = sslCtx.setOCSPOptions(ocspOptions);
if (ret != WolfSSL.SSL_SUCCESS) {
System.out.println("failed to set OCSP options, ret = "
+ ret);
System.exit(1);
long ocspOptions = WolfSSL.CYASSL_OCSP_NO_NONCE;
if (ocspUrl != null) {
ocspOptions = ocspOptions |
WolfSSL.CYASSL_OCSP_URL_OVERRIDE;
}
if (ocspUrl != null) {
@ -257,6 +256,13 @@ public class Client {
System.exit(1);
}
}
ret = sslCtx.enableOCSP(ocspOptions);
if (ret != WolfSSL.SSL_SUCCESS) {
System.out.println("failed to enable OCSP, ret = "
+ ret);
System.exit(1);
}
}
/* create SSL object */

View File

@ -240,13 +240,12 @@ public class Server {
/* set OCSP options, override URL */
if (useOcsp == 1) {
long ocspOptions = WolfSSL.CYASSL_OCSP_ENABLE |
WolfSSL.CYASSL_OCSP_NO_NONCE;
ret = sslCtx.setOCSPOptions(ocspOptions);
if (ret != WolfSSL.SSL_SUCCESS) {
System.out.println("failed to set OCSP options, ret = "
+ ret);
System.exit(1);
long ocspOptions = WolfSSL.CYASSL_OCSP_NO_NONCE;
if (ocspUrl != null) {
ocspOptions = ocspOptions |
WolfSSL.CYASSL_OCSP_URL_OVERRIDE;
}
if (ocspUrl != null) {
@ -257,6 +256,13 @@ public class Server {
System.exit(1);
}
}
ret = sslCtx.enableOCSP(ocspOptions);
if (ret != WolfSSL.SSL_SUCCESS) {
System.out.println("failed to enable OCSP, ret = "
+ ret);
System.exit(1);
}
}
/* create server socket, later if DTLS */
@ -495,6 +501,9 @@ public class Server {
System.out.println("-d\t\tDisable peer checks");
System.out.println("-iocb\t\tEnable test I/O callbacks");
System.out.println("-logtest\tEnable test logging callback");
System.out.println("-o\t\tPerform OCSP lookup on peer certificate");
System.out.println("-O <url>\tPerform OCSP lookup using <url> " +
"as responder");
System.out.println("-U\t\tAtomic User Record Layer Callbacks");
System.out.println("-P\t\tPublic Key Callbacks");
System.out.println("-m\t\tEnable CRL directory monitor");

View File

@ -75,12 +75,10 @@ extern "C" {
#define com_wolfssl_WolfSSL_SSL_ERROR_SSL 85L
#undef com_wolfssl_WolfSSL_CYASSL_CRL_CHECKALL
#define com_wolfssl_WolfSSL_CYASSL_CRL_CHECKALL 1L
#undef com_wolfssl_WolfSSL_CYASSL_OCSP_ENABLE
#define com_wolfssl_WolfSSL_CYASSL_OCSP_ENABLE 1L
#undef com_wolfssl_WolfSSL_CYASSL_OCSP_URL_OVERRIDE
#define com_wolfssl_WolfSSL_CYASSL_OCSP_URL_OVERRIDE 2L
#define com_wolfssl_WolfSSL_CYASSL_OCSP_URL_OVERRIDE 1L
#undef com_wolfssl_WolfSSL_CYASSL_OCSP_NO_NONCE
#define com_wolfssl_WolfSSL_CYASSL_OCSP_NO_NONCE 4L
#define com_wolfssl_WolfSSL_CYASSL_OCSP_NO_NONCE 2L
#undef com_wolfssl_WolfSSL_CYASSL_CBIO_ERR_GENERAL
#define com_wolfssl_WolfSSL_CYASSL_CBIO_ERR_GENERAL -1L
#undef com_wolfssl_WolfSSL_CYASSL_CBIO_ERR_WANT_READ

View File

@ -1302,10 +1302,16 @@ void NativeCtxMissingCRLCallback(const char* url)
}
}
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_setOCSPOptions
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_enableOCSP
(JNIEnv* jenv, jobject jcl, jlong ctx, jlong options)
{
return CyaSSL_CTX_OCSP_set_options((CYASSL_CTX*)ctx, options);
return CyaSSL_CTX_EnableOCSP((CYASSL_CTX*)ctx, options);
}
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_disableOCSP
(JNIEnv* jenv, jobject jcl, jlong ctx)
{
return CyaSSL_CTX_DisableOCSP((CYASSL_CTX*)ctx);
}
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_setOCSPOverrideUrl
@ -1332,7 +1338,7 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_setOCSPOverrideUrl
url = (*jenv)->GetStringUTFChars(jenv, urlString, 0);
ret = (jint) CyaSSL_CTX_OCSP_set_override_url((CYASSL_CTX*)ctx, url);
ret = (jint) CyaSSL_CTX_SetOCSP_OverrideURL((CYASSL_CTX*)ctx, url);
(*jenv)->ReleaseStringUTFChars(jenv, urlString, url);

View File

@ -193,12 +193,20 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_setCRLCb
/*
* Class: com_wolfssl_WolfSSLContext
* Method: setOCSPOptions
* Method: enableOCSP
* Signature: (JJ)I
*/
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_setOCSPOptions
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_enableOCSP
(JNIEnv *, jobject, jlong, jlong);
/*
* Class: com_wolfssl_WolfSSLContext
* Method: disableOCSP
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_disableOCSP
(JNIEnv *, jobject, jlong);
/*
* Class: com_wolfssl_WolfSSLContext
* Method: setOCSPOverrideUrl

View File

@ -115,9 +115,8 @@ public class WolfSSL {
/* extra definitions from ssl.h */
public final static int CYASSL_CRL_CHECKALL = 1;
public final static int CYASSL_OCSP_ENABLE = 0x0001;
public final static int CYASSL_OCSP_URL_OVERRIDE = 0x0002;
public final static int CYASSL_OCSP_NO_NONCE = 0x0004;
public final static int CYASSL_OCSP_URL_OVERRIDE = 1;
public final static int CYASSL_OCSP_NO_NONCE = 2;
/* I/O callback default errors, pulled from cyassl/ssl.h IOerrors */
public final static int CYASSL_CBIO_ERR_GENERAL = -1;

View File

@ -288,7 +288,8 @@ public class WolfSSLContext {
private native int disableCRL(long ctx);
private native int loadCRL(long ctx, String path, int type, int monitor);
private native int setCRLCb(long ctx, WolfSSLMissingCRLCallback cb);
private native int setOCSPOptions(long ctx, long options);
private native int enableOCSP(long ctx, long options);
private native int disableOCSP(long ctx);
private native int setOCSPOverrideUrl(long ctx, String url);
private native void setMacEncryptCb(long ctx);
private native void setDecryptVerifyCb(long ctx);
@ -911,10 +912,10 @@ public class WolfSSLContext {
}
/**
* Sets options to configure behavior of OCSP functionality in wolfSSL.
* Enable OCSP functionality for this context, set options.
* The value of <b>options</b> is formed by OR'ing one or more of the
* following options:<br/>
* <b>CYASSL_OCSP_ENABLE</b> - enable OCSP lookups<br/>
* <b>CYASSL_OCSP_NO_NONCE</b> - disable sending OCSP nonce<br/>
* <b>CYASSL_OCSP_URL_OVERRIDE</b> - use the override URL instead of the
* URL in certificates</br>
* This function only sets the OCSP options when wolfSSL has been
@ -923,13 +924,27 @@ public class WolfSSLContext {
* @param options value used to set the OCSP options
* @return <b><code>SSL_SUCCESS</code></b> upon success,
* <b><code>SSL_FAILURE</code></b> upon failure,
* <b><code>BAD_FUNC_ARG</code></b> if context is null,
* <b><code>MEMORY_E</code></b> upon memory error,
* <b><code>NOT_COMPILED_IN</code></b> when this function
* has been called, but OCSP support was not enabled when
* wolfSSL was compiled.
* @see #disableOCSP
* @see #setOCSPOverrideUrl(String)
*/
public int setOCSPOptions(long options) {
return setOCSPOptions(getContextPtr(), options);
public int enableOCSP(long options) {
return enableOCSP(getContextPtr(), options);
}
/**
* Disable OCSP for this context.
* @return <b><code>SSL_SUCCESS</code></b> upon success,
* <b><code>BAD_FUNC_ARG</code></b> if context is null,
* @see #enableOCSP(long)
* @see #setOCSPOverrideUrl(String)
*/
public int disableOCSP() {
return disableOCSP(getContextPtr());
}
/**
@ -944,7 +959,8 @@ public class WolfSSLContext {
* <b><code>NOT_COMPILED_IN</code></b> when this function has
* been called, but OCSP support was not enabled when
* wolfSSL was compiled.
* @see #setOCSPOptions(long)
* @see #enableOCSP(long)
* @see #disableOCSP
*/
public int setOCSPOverrideUrl(String url) {
return setOCSPOverrideUrl(getContextPtr(), url);

View File

@ -53,7 +53,7 @@ public class WolfSSLTest extends TestCase {
tstMethod(lib.DTLSv1_ClientMethod(), "DTLSv1_ClientMethod()");
tstMethod(lib.DTLSv1_2_ServerMethod(), "DTLSv1_2_ServerMethod()");
tstMethod(lib.DTLSv1_2_ClientMethod(), "DTLSv1_2_ClientMethod()");
tstMethod(lib.SSLv23_ServerMethod(), "SSLv23__ServerMethod()");
tstMethod(lib.SSLv23_ServerMethod(), "SSLv23_ServerMethod()");
tstMethod(lib.SSLv23_ClientMethod(), "SSLv23_ClientMethod()");
}