Skip to content

OCSP stapling support for Netty using netty-tcnative.#6158

Closed
rkapsi wants to merge 1 commit intonetty:4.1from
Squarespace:rkapsi/netty-ocsp
Closed

OCSP stapling support for Netty using netty-tcnative.#6158
rkapsi wants to merge 1 commit intonetty:4.1from
Squarespace:rkapsi/netty-ocsp

Conversation

@rkapsi
Copy link
Copy Markdown
Member

@rkapsi rkapsi commented Dec 27, 2016

OCSP stapling support for Netty using netty-tcnative.

netty/netty-tcnative#215

Motivation

OCSP stapling (formally known as TLS Certificate Status Request extension) is alternative approach for checking the revocation status of X.509 Certificates. Servers can preemptively fetch the OCSP response from the CA's responder, cache it for some period of time, and pass it along during (a.k.a. staple) the TLS handshake. The client no longer has to reach out on its own to the CA to check the validity of a cetitficate. Some of the key benefits are:

  1. Speed. The client doesn't have to crosscheck the certificate.
  2. Efficiency. The Internet is no longer DDoS'ing the CA's OCSP responder servers.
  3. Safety. Less operational dependence on the CA. Certificate owners can sustain short CA outages.
  4. Privacy. The CA can lo longer track the users of a certificate.

https://en.wikipedia.org/wiki/OCSP_stapling
https://letsencrypt.org/2016/10/24/squarespace-ocsp-impl.html

Modifications

https://www.openssl.org/docs/man1.0.2/ssl/SSL_set_tlsext_status_type.html

Result

High-level API to enable OCSP stapling

@rkapsi
Copy link
Copy Markdown
Member Author

rkapsi commented Dec 27, 2016

Build fails because this change depends on a version of netty-tcnative that isn't released yet: netty/netty-tcnative#215

I was planning to include also an example for how to pull out the OCSP responder URL from the X509 Certificate and retrieve the OCSP staple from the CA but it'll require Bouncycastle.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add this to the style guide but can you keep the statics at the bottom, and preserve the previous import order?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should 0 be TLSEXT_STATUSTYPE_host_name?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SSL.setStatusType protects against null SSL* too ... can we just rely on the null there instead of doing it in both places?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we instead unwrap and verify the NPE?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we run this test with OPENSSL_REFCNT too? We need to be careful about releasing in this case of course.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider specifying the timeout values here so the unit tests don't have to wait for the quite period etc...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just do assertTrue?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is expected to be called in the junit thread right, if so can we just do assertTrue?

@rkapsi rkapsi force-pushed the rkapsi/netty-ocsp branch from 40724c8 to f398f75 Compare February 8, 2017 22:54
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test and testServerException produce the NPE described in #6336.

OpenSSL calls the verify() method (via the OCSP callback - see PR in netty-tcnative) and this test throws purposely an IllegalStateException to see what happens.

I'm expecting a DecoderException to bubble up (with the IllegalStateException as cause) but instead I'm getting DecoderException that was caused by a NPE.

@rkapsi rkapsi force-pushed the rkapsi/netty-ocsp branch 2 times, most recently from 5bc87a1 to f51de8e Compare February 9, 2017 14:20
@rkapsi rkapsi force-pushed the rkapsi/netty-ocsp branch 3 times, most recently from bec5a7f to 8dde6fb Compare February 24, 2017 18:33
@rkapsi
Copy link
Copy Markdown
Member Author

rkapsi commented Feb 24, 2017

@Scottmitch I've added some example code to the PR. The client side is pretty simple but likely not very useful. The server side is more interesting as it involves pulling out the CA's OCSP responder URL from the X509 Certificate and then constructing a special POST request to obtain the OCSP staple from the said URL. It's a somewhat involved process and there isn't much information about it on the Intertubes. I tried to keep the examples as simple as possible and they're not meant to be an example how do run this code in production.

I used Wikipedia's Webserver for the client example because the CDN that is fronting netty.io doesn't support OCSP. And I used netty.io's X509 Certificate (Comodo) for the server example but it's incomplete because I don't have the PrivateKey for it.

Copy link
Copy Markdown
Member

@Scottmitch Scottmitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few comments but looking good!

I didn't look too closely at OcspServerExample. It would be nice if we could make this work with the client example ... not sure how much additional effort this would require though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see netty/netty-tcnative#215 ... does this account for checking of the runtime version which may be dynamically linked?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That cert chain is actually not generated. It's the real cert chain for https://netty.io and it was simply pulled with Chrome's export feature.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment to explain null is allowed and that it will free the existing callback if one exists.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you mix 2 and 4 space indentation here ... can you make this consistent?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: package private?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding a descriptive string: e.g socket was closed before response was received.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding a descriptive error string for the exception

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an one-time -> a one-time

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also aren't you randomly generating the nonce on each build?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, a new nonce is created for each build(). The comment is referring to the built object itself because it's tempting to cache that OCSPReq object.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a define for this value?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮

Consider adding a comment // TODO: use Netty 😉

@Scottmitch Scottmitch self-assigned this Mar 2, 2017
@rkapsi rkapsi force-pushed the rkapsi/netty-ocsp branch 2 times, most recently from 2fc4adf to 9405451 Compare March 6, 2017 19:45
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you link to the RFC or area where this ID is define? these magic IDs have a tendency to spread around without any reference to where they came from.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify why having a self signed certificate is prohibitive and why it wouldn't be possible for the server to simulate querying the CA for the staple ... and just generate it on demand (via bc, openssl, etc...)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a race condition here where callback may be used after freeOcspCallback is called on the callback. Consider the following:

  • adding a constraint (via javadoc APIs) on OcspCallbackExt that this use case must be supported (no negative behavior will result from calling callback.context() or using the resulting object after freeOcspCallback is called).
  • adding a warning on this method that unexpected results may occur if the underlying object is freed.
  • remove this method (doesn't look like its used currently).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it would be more clear if the 0 value came from tcnative instead of implicitly defined at the Netty level.

Thinking about it more TlsExtStatusType is not very descriptive and I'm not sure if it would require state in the future to use if different options are supported through this interface. I get why BoringSSL decided to go with SSL_enable_ocsp_stapling ... can we just use this API naming convention in tcnative instead of OpenSSL's? @normanmaurer - WDYT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. Happy to change it into enableOcsp() as there is no use-case for the toggle functionality.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider saving a reference to this exception ... just to ensure the same value is used in the comparison and string printout.

(general comment for this test)

@rkapsi rkapsi force-pushed the rkapsi/netty-ocsp branch 2 times, most recently from ea41995 to 0f41465 Compare March 7, 2017 22:35
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should revert this back to a plain JDK implementation (i.e. HttpURLConnection) and provide it just a short and simple example how to interact with the CA's responder as there's not much information about it on the Internet (or rather it's difficult to formulate the query as OCSP is foreign to many ppl.)

Once you know that it's a HTTP POST, with special content-type and accept headers and a special payload it's "trivial" to deduct a Netty client from it.

In general, in order to operate OCSP you need to build some infrastructure that goes beyond the Netty project. You need caches, an OCSP responder client (i.e. something like this class) and a strategy to manage and refresh all these staples that are only valid for < 10 days.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with that for the sake of an example, and assuming we can't or its too much hassle to implement a more self contained example #6158 (comment). My previous comment on this was meant to literally add something like // TODO: we use HttpURLConnection for the sake of demonstration, but you should consider using Netty's HTTP client instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update this comment.

Copy link
Copy Markdown
Member

@Scottmitch Scottmitch Mar 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum this relationship is unnatural. Typically the SSLContext provides the default configuration for creating an SSLEngine and the same relationship olds for SSL_CTX and SSL, and the SSL/SSLEngine never impacts the state of the SSL_CTX/SSLContext. Could we just instead have tcnative throw if the SSL_CTX has not been setup correctly? For example we could add a bool oscp_enabled to tcn_ssl_ctxt_t (in ssl_private.h). SSLContext#enableOcsp would set this state (even for BoringSSL) and then SSL#enableOcsp would check this state has been set. You can get the tcn_ssl_ctxt_t from the SSL* via SSL_get_app_data2.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Next PR fixes it. I've reduced it to:

SSLContext#enableOcsp
SSL#setOcspResponse
SSL#getOcspResponse

The SSL#enableOcsp call doesn't need to be exposed to the user.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: make a tertiary statement.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this just be removed before the verification?

@normanmaurer
Copy link
Copy Markdown
Member

Sorry @Scottmitch @rkapsi but I had no time yet to look at this... Will try to do over the next days

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove empty line

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove empty line

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8192

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkapsi is this good enough and also hold true for Libressl and Boringssl ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I don't know. I'm operating under the assumption they're forks of OpenSSL and OCSP should be present as of 1.0.0 and we have only tested 1.0.2+.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe try to run the test while using "netty-tcnative-boringssl-static" and see what happens :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, LibreSSL works.

BoringSSL doesn't work (fails gracefully with my OCSP is not supported exception) but that is because... It's either getting built with OPENSSL_NO_OCSP or OPENSSL_VERSION_NUMBER is something very different than expected. Checking... 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirm, BoringSSL gets built with OPENSSL_NO_OCSP.

Copy link
Copy Markdown
Member

@Scottmitch Scottmitch Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming @davidben.

@nmittler - We are working with @rkapsi to support both BoringSSL and OpenSSL (and LibreSSL should come for "free"). We are currently using both APIs to make this happen and it is just a matter of working out the kinks to make sure we can make the two different APIs (BoringSSL and OpenSSL) work consistently with one API (tcnative/netty) on top. I think we are very close to pulling this off (thanks to @rkapsi !)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In regards to the machinery: That is totally cool that BoringSSL doesn't support the heavy machinery because we don't use any of OpenSSL's either. All we want to do is blindly pass along byte strings. It's literally just that and BoringSSL's API does just that. Again, totally cool. Unfortunately it's defaulting to OPENSSL_NO_OCSP and I guess we're confused how to proceed. 🤔

I'm personally cool not supporting BoringSSL but that means I'll never be able to use it either because our lovely non-profit CA will not appreciate it being DDoS'd if our servers do handshakes without staples.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OPENSSL_NO_OCSP means we do not support OpenSSL's OCSP API. If we did not define it, loads of projects would fail to build because they, naturally, do not use BoringSSL's API. Like with any other project, your options are not to support OCSP stapling with BoringSSL (in which case OPENSSL_NO_OCSP, what you would have been checking anyway, Just Works and you need no additional work) or to add BoringSSL-specific code that does not look at OPENSSL_NO_OCSP. BoringSSL-specific code is obviously needed anyway for BoringSSL-specific API, so I don't see why having to ignore a preprocessor symbol which happens to have a similar name as the feature matters.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case this is where the confusion comes from, BoringSSL's APIs has no relation to OPENSSL_NO_OCSP. They are available regardless.

We do not, in general, have individual toggles for all our features like OpenSSL does. Instead, we define a set of OPENSSL_NO_* values based on what makes portability simplest. These symbols do not affect what features BoringSSL exposes.

Copy link
Copy Markdown
Member

@Scottmitch Scottmitch Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed I think we have the tools we need and everything is ok :)

@rkapsi we just need to adjust the macros see netty/netty-tcnative#215 (comment) ... I will add more details here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected as the class is abstract

Copy link
Copy Markdown
Member Author

@rkapsi rkapsi Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making it protected would prevent ad-hoc instantiation and force the user to declare a class which can be a nuisance for prototyping/quick hackery.

// This won't be possible with a protected ctor
pipeline.addLast(new OcspClientHandler(engine) {
  @Override
  public boolean verify(...) {
    return true;
  }
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkapsi - are you sure? I don't see why this would cause an issue, can you explain? OcspClientHandler is an anonymous type that should have access to protected things in the super class.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Operator error, disregard me.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using a do {} while(...) loop as it should not be called with a null Throwable

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just return directly

pom.xml Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.0.1.Final-SNAPSHOT now :)

@rkapsi rkapsi force-pushed the rkapsi/netty-ocsp branch from cfaf2e2 to d80bf08 Compare March 9, 2017 15:05
Copy link
Copy Markdown
Member

@Scottmitch Scottmitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new approach :) few more comments too

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we treat this as an error if called while in the wrong mode?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkapsi - are you sure? I don't see why this would cause an issue, can you explain? OcspClientHandler is an anonymous type that should have access to protected things in the super class.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider testing with both providers (OPENSSL_REFCNT) like other tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider testing with both providers (OPENSSL_REFCNT) like other tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider blocking on the channel close futures. If the event loop is closed before the channels close we could leak buffers (close may execute a task on the event loop to cleanup internal queues).

Copy link
Copy Markdown
Member

@Scottmitch Scottmitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few remaining comments the lgtm ... great job @rkapsi !

pom.xml Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this after you are done testing

@rkapsi rkapsi force-pushed the rkapsi/netty-ocsp branch 3 times, most recently from 119dda6 to 9d624e7 Compare March 13, 2017 21:42
Copy link
Copy Markdown
Member

@Scottmitch Scottmitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few more comments/questions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we create this request when it is needed? Otherwise we risk leaking this reference counted object.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 * 1024 * 1024 -> 1024 * 1024?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: consider simplifying these conditional statements

return status == CertificateStatus.GOOD && certSerial.equals(ocspSerial);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: make this a javadoc comment so the link shows up in IDEs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the intention to dynamically toggle this value? For example is it sufficient to just add a method to the SslContextBuilder and configure it in the constructor of this method.

For example isn't there some assumptions from the SSL's perspective that the SSL_CTX has some callback set? We may be OK if we only ever allow a transition from disabled -> enabled, but it may introduce undefined behavior if we forget this relationship and add a enabled -> disabled transition.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move it into SslContextBuilder and it's only allowed to transition from disabled to enabled.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider creating this exception outside the scope and check for assertSame below:

final OcspTestException clientException = new OcspTestException("testClientException");

...
@Override
public boolean verify(byte[] response) throws Exception {
  throw clientException;
}
...

assertSame(clientException, causeRef.get());

pom.xml Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder: we need to update this at some point. (/cc @normanmaurer )

@rkapsi rkapsi force-pushed the rkapsi/netty-ocsp branch 2 times, most recently from b85844d to 765ad9c Compare March 28, 2017 20:36
@rkapsi
Copy link
Copy Markdown
Member Author

rkapsi commented Mar 28, 2017

@Scottmitch moved the enableOcsp() method to SslContextBuilder, made your suggested changes and added two unit tests for JDK SSL impl. which don't support OCSP and should blow up.

Copy link
Copy Markdown
Member

@Scottmitch Scottmitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few more comments ... then rebase/squash and I will merge.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: consider simplifying to the following:

return status == CertificateStatus.GOOD && certSerial.equals(ocspSerial);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the engine must be released at some point. SslHandler typically takes ownership, but it must be interred into a pipeline ignorer to do so.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the engine must be released at some point. SslHandler typically takes ownership, but it must be interred into a pipeline ignorer to do so.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @Scottmitch said... add engine.release() to the finally block

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClientOcspContext cannot be found. Update this comment plz.

Copy link
Copy Markdown
Member

@normanmaurer normanmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address my comments. Also please note we should not merge this until a new netty-tcnative version is released that supports the needed API

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @Scottmitch said... add engine.release() to the finally block

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @Scottmitch said... add engine.release() to the finally block

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBytes(CharsetUtil.US_ASCII)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also just remove the message... I think its clear that something went wrong here ;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit remove empty line

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge these two branches:

if (((SslHandshakeCompletionEvent) evt).isSuccess() && !verify(ctx, engine)) {
    throw OCSP_VERIFICATION_EXCEPTION;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the provider to the message

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reduce the scope of the synchronized block:

public void setOcspResponse(byte[] response) {
     if (!enableOcsp) {
         throw new IllegalStateException("OCSP stapling is not enabled");
     }
 
     if (clientMode) {
         throw new IllegalStateException("Not a server SSLEngine");
     }

     synchronized(this) {
         SSL.setOcspResponse(ssl, response);
     }
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkapsi rkapsi force-pushed the rkapsi/netty-ocsp branch from 765ad9c to 432e439 Compare March 31, 2017 13:11
@rkapsi
Copy link
Copy Markdown
Member Author

rkapsi commented Mar 31, 2017

@Scottmitch @normanmaurer - done!

Copy link
Copy Markdown
Member

@Scottmitch Scottmitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work @rkapsi ! We will merge when tcnative is released.

@Scottmitch
Copy link
Copy Markdown
Member

@normanmaurer - Note the necessary changes for tcnative have already been merged. So if we plan to update the version of tcnative for the next version of Netty we could merge this now.

@rkapsi - Please rebase to resolve recently introduced conflicts.

@rkapsi rkapsi force-pushed the rkapsi/netty-ocsp branch from 432e439 to a93e9e4 Compare April 3, 2017 14:47
@rkapsi
Copy link
Copy Markdown
Member Author

rkapsi commented Apr 3, 2017

@Scottmitch - done.

@Scottmitch
Copy link
Copy Markdown
Member

the build failed due to a recent API change in netty-tcnative. I merged the corresponding Netty PR #6581 which should resolve the issue. Can you rebase again?

netty/netty-tcnative#215

Motivation

OCSP stapling (formally known as TLS Certificate Status Request extension) is alternative approach for checking the revocation status of X.509 Certificates. Servers can preemptively fetch the OCSP response from the CA's responder, cache it for some period of time, and pass it along during (a.k.a. staple) the TLS handshake. The client no longer has to reach out on its own to the CA to check the validity of a cetitficate. Some of the key benefits are:

1) Speed. The client doesn't have to crosscheck the certificate.
2) Efficiency. The Internet is no longer DDoS'ing the CA's OCSP responder servers.
3) Safety. Less operational dependence on the CA. Certificate owners can sustain short CA outages.
4) Privacy. The CA can lo longer track the users of a certificate.

https://en.wikipedia.org/wiki/OCSP_stapling
https://letsencrypt.org/2016/10/24/squarespace-ocsp-impl.html

Modifications

https://www.openssl.org/docs/man1.0.2/ssl/SSL_set_tlsext_status_type.html

Result

High-level API to enable OCSP stapling
@rkapsi rkapsi force-pushed the rkapsi/netty-ocsp branch from a93e9e4 to 27450c9 Compare April 3, 2017 18:16
@rkapsi
Copy link
Copy Markdown
Member Author

rkapsi commented Apr 3, 2017

@Scottmitch - done.

@Scottmitch
Copy link
Copy Markdown
Member

4.1 (077a198) 4.0 (305e788)

@Scottmitch Scottmitch closed this Apr 3, 2017
@Scottmitch
Copy link
Copy Markdown
Member

Great work! Thanks for your patience @rkapsi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants