Repository navigation
Allow to set CA list for SSLContext via BIO - #211
normanmaurer wants to merge 1 commit into
Conversation
| return rv; | ||
| } | ||
|
|
||
| TCN_IMPLEMENT_CALL(jboolean, SSLContext, setCACertificateBio)(TCN_STDARGS, |
There was a problem hiding this comment.
It doesn't look like the return value is used ... should we just make this method void and throw if something goes wrong?
There was a problem hiding this comment.
I think we should return jboolean and use it :)
| TCN_ASSERT(ctx != 0); | ||
|
|
||
| if (b == NULL) { | ||
| return JNI_FALSE; |
There was a problem hiding this comment.
if we want to keep this method as boolean then we could change to this:
return b != NULL && c->mode != SSL_MODE_CLIENT && SSL_CTX_use_client_CA_bio(c->ctx, b) > 0 ? JNI_TRUE : JNI_FALSE;| if (SSL_CTX_add_extra_chain_cert(ctx, x509) != 1) { | ||
| X509_free(x509); | ||
| return -1; | ||
| if (ca == 1) { |
There was a problem hiding this comment.
make this data type jboolean and/or treat it as a boolean if (ca) { .. }?
| } | ||
|
|
||
| int SSL_CTX_use_certificate_chain_bio(SSL_CTX *ctx, BIO *bio, | ||
| int skipfirst) |
There was a problem hiding this comment.
move this argument to the previous line?
| * <br> | ||
| * @param ctx Server context to use. | ||
| * @param certBio Directory of PEM-encoded CA Certificates for Client Auth. | ||
| */ |
There was a problem hiding this comment.
make this void or add a @returns describing the return value.
5bcce9c to
5ef6783
Compare
| BIO *b = J2P(certs, BIO *); | ||
|
|
||
| UNREFERENCED(o); | ||
| TCN_ASSERT(ctx != 0); |
There was a problem hiding this comment.
sure we can do... just made it consistent with the rest of the methods .
|
|
||
| int SSL_CTX_use_certificate_chain_bio(SSL_CTX *ctx, BIO *bio, | ||
| int skipfirst) | ||
| static int SSL_CTX_setup_certs(SSL_CTX *ctx, BIO *bio, int skipfirst, int ca) |
There was a problem hiding this comment.
what c standard do we target, c99? If so consider using #include <stdbool.h> and bool
There was a problem hiding this comment.
good question. I just used what we used in other methods. So keep it for now as it is ?
There was a problem hiding this comment.
I prefer to be explicit about types when possible in typed languages. If its an int then compare it to an explicit value, if its a bool then use it like a boolean. For example below we use the int like a boolean and there is nothing that describes this assumption ... making it a bool removes the ambiguity.
There was a problem hiding this comment.
@Scottmitch I think I would like to keep it as it is and cleanup all the methods in a followup PR as this should be done for all the methods in all classes where we use an int as bool. Ok ?
There was a problem hiding this comment.
@normanmaurer - Do you have other examples where we do this? As long as we clean it up that is fine with me.
There was a problem hiding this comment.
actually its the same method or methods that call it... skipfirst is also just a boolean.
5ef6783 to
c6c03a1
Compare
Motivation: To correct announce CA list we need to allow setting it via a BIO so we can hook it up with the X509TrustManager. This is needed to fix netty/netty#6141 . Modifications: Add new SSLContext.setCACertifcateBio(...) method Result: Be able to set the to be announced CA list.
e3b7748 to
2611b72
Compare
Motivation:
To correct announce CA list we need to allow setting it via a BIO so we can hook it up with the X509TrustManager.
This is needed to fix netty/netty#6141 .
Modifications:
Add new SSLContext.setCACertifcateBio(...) method
Result:
Be able to set the to be announced CA list.