Skip to content

Commit 41dc454

Browse files
authored
Merge pull request fooinha#6 from fooinha/fix/travis
nginx-ssl-ja3: update nginx patches
2 parents 1f2d300 + 83a088e commit 41dc454

File tree

4 files changed

+94
-5
lines changed

4 files changed

+94
-5
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ script:
3636
- make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1)
3737
- sudo make install > build.log 2>&1 || (cat build.log && exit 1)
3838
- cd ..
39-
- cp -v docker/debian-nginx-ssl-ja3/nginx.ssl.extensions.patch nginx/.
39+
- cp -v docker/debian-nginx-ssl-ja3/nginx.1.15.9.ssl.extensions.patch nginx/.
4040
- cd nginx
41-
- patch -p1 < nginx.ssl.extensions.patch
41+
- patch -p1 < nginx.1.15.9.ssl.extensions.patch
4242
- auto/configure --with-debug --with-stream --with-ld-opt="-Wl,-E -L /usr/local/lib" --prefix=$NGINX_PREFIX --with-http_ssl_module --with-stream_ssl_module --add-module=.. > build.log 2>&1 || (cat build.log && exit 1)
4343
- make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1)
4444
- sudo make install > build.log 2>&1 || (cat build.log && exit 1)

docker/debian-nginx-ssl-ja3/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ RUN hg clone http://hg.nginx.org/nginx
8080

8181
# Patch nginx for fetching ssl client extensions
8282
WORKDIR /build/nginx
83-
COPY nginx.ssl.extensions.patch /build/nginx
84-
RUN cat nginx.ssl.extensions.patch
85-
RUN patch -p1 < nginx.ssl.extensions.patch
83+
COPY nginx.1.15.9.ssl.extensions.patch /build/nginx
84+
RUN patch -p1 < nginx.1.15.9.ssl.extensions.patch
8685

8786
# Configure, make and install
8887
RUN ./auto/configure --add-module=/build/nginx-ssl-ja3 --with-http_ssl_module --with-stream_ssl_module --with-stream --with-debug --with-ld-opt="-L/usr/local/lib -Wl,-E"
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
diff -r 2e8de3d81783 src/event/ngx_event_openssl.c
2+
--- a/src/event/ngx_event_openssl.c Tue Aug 22 17:36:12 2017 +0300
3+
+++ b/src/event/ngx_event_openssl.c Tue Aug 22 20:20:30 2017 +0000
4+
@@ -1221,6 +1221,60 @@
5+
}
6+
7+
8+
+#if OPENSSL_VERSION_NUMBER >= 0x10101000L
9+
+
10+
+int
11+
+ngx_SSL_early_cb_fn(SSL *s, int *al, void *arg) {
12+
+
13+
+ int got_extensions;
14+
+ int *ext_out;
15+
+ size_t ext_len;
16+
+ ngx_connection_t *c;
17+
+
18+
+ c = arg;
19+
+
20+
+ if (c == NULL) {
21+
+ return 1;
22+
+ }
23+
+
24+
+ if (c->ssl == NULL) {
25+
+ return 1;
26+
+ }
27+
+
28+
+ c->ssl->client_extensions_size = 0;
29+
+ c->ssl->client_extensions = NULL;
30+
+
31+
+ got_extensions = SSL_client_hello_get1_extensions_present(s,
32+
+ &ext_out,
33+
+ &ext_len);
34+
+ if (!got_extensions) {
35+
+ return 1;
36+
+ }
37+
+
38+
+ if (!ext_out) {
39+
+ return 1;
40+
+ }
41+
+
42+
+ if (!ext_len) {
43+
+ return 1;
44+
+ }
45+
+
46+
+ c->ssl->client_extensions = ngx_palloc(c->pool, sizeof(int) * ext_len);
47+
+ if (c->ssl->client_extensions == NULL) {
48+
+ OPENSSL_free(ext_out);
49+
+ return 1;
50+
+ }
51+
+
52+
+ c->ssl->client_extensions_size = ext_len;
53+
+ ngx_memcpy(c->ssl->client_extensions, ext_out, sizeof(int) * ext_len);
54+
+
55+
+ OPENSSL_free(ext_out);
56+
+
57+
+ return 1;
58+
+}
59+
+#endif
60+
+
61+
+
62+
ngx_int_t
63+
ngx_ssl_handshake(ngx_connection_t *c)
64+
{
65+
@@ -1229,6 +1283,10 @@
66+
67+
ngx_ssl_clear_error(c->log);
68+
69+
+#if OPENSSL_VERSION_NUMBER >= 0x10101000L
70+
+ SSL_CTX_set_client_hello_cb(c->ssl->session_ctx, ngx_SSL_early_cb_fn, c);
71+
+#endif
72+
+
73+
n = SSL_do_handshake(c->ssl->connection);
74+
75+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_do_handshake: %d", n);
76+
diff -r 2e8de3d81783 src/event/ngx_event_openssl.h
77+
--- a/src/event/ngx_event_openssl.h Tue Aug 22 17:36:12 2017 +0300
78+
+++ b/src/event/ngx_event_openssl.h Tue Aug 22 20:20:30 2017 +0000
79+
@@ -98,6 +98,11 @@
80+
unsigned in_early:1;
81+
unsigned early_preread:1;
82+
unsigned write_blocked:1;
83+
+
84+
+#if OPENSSL_VERSION_NUMBER >= 0x10101000L
85+
+ size_t client_extensions_size;
86+
+ int *client_extensions;
87+
+#endif
88+
};
89+
90+

0 commit comments

Comments
 (0)