2018-04-07 08:19:17 +00:00
# openssl-patch
2018-12-07 13:24:47 +00:00
## OpenSSL Patch
2018-04-07 08:43:00 +00:00
2018-06-01 04:26:27 +00:00
### This file is not an official OpenSSL patch. Problems can arise and this is your responsibility.
2018-05-30 05:45:57 +00:00
2018-06-08 17:44:43 +00:00
## Original Sources
2018-06-08 17:45:45 +00:00
- [OpenSSL Equal Preference Patch ](https://boringssl.googlesource.com/boringssl/+/858a88daf27975f67d9f63e18f95645be2886bfb%5E%21 ) by [BoringSSL ](https://github.com/google/boringssl ) & [buik ](https://gitlab.com/buik/openssl/blob/openssl-patch/openssl-1.1 )
2018-06-08 17:44:43 +00:00
- [HPACK Patch ](https://github.com/cloudflare/sslconfig/blob/master/patches/nginx_1.13.1_http2_hpack.patch ) by [Cloudflare ](https://github.com/cloudflare/sslconfig )
2018-09-15 17:33:44 +00:00
- [nginx Strict-SNI Patch ](https://github.com/hakasenyang/openssl-patch/issues/1#issuecomment-421551872 ) by [@JemmyLoveJenny ](https://github.com/JemmyLoveJenny )
2018-10-11 06:21:17 +00:00
- [OpenSSL OLD-CHACHA20-POLY1305 ](https://github.com/JemmyLoveJenny/ngx_ossl_patches ) by [@JemmyLoveJenny ](https://github.com/JemmyLoveJenny )
2019-04-25 11:00:11 +00:00
- [OpenSSL 1.1.1c PrioritizeChacha Patch ](https://github.com/hakasenyang/openssl-patch/pull/17 ) by [@felixbuenemann ](https://github.com/felixbuenemann )
2018-06-08 17:44:43 +00:00
## Information
2019-05-02 11:03:09 +00:00
- [Test Page - (TLS 1.3 final) ](https://ssl.haka.se/ )
- [SSL Test Result - testssl.sh ](https://ssl.haka.se/ssltest/haka.se.html )
- [SSL Test Result - dev.ssllabs.com ](https://dev.ssllabs.com/ssltest/analyze.html?d=haka.se )
2019-02-09 11:31:04 +00:00
- **If you link site to a browser that supports final, you'll see a TLS 1.3 message.**
2018-06-01 04:33:35 +00:00
2018-08-17 04:15:58 +00:00
Displays TLSv1.3 support for large sites.
2018-08-17 04:16:44 +00:00
2018-08-17 04:15:58 +00:00
Default support is in bold type.
2018-08-22 15:13:33 +00:00
- [Baidu(China) ](https://baidu.cn/ ) : **TLSv1.2**
- [Naver(Korea) ](https://naver.com/ ) : **TLSv1.2**
- [Twitter ](https://twitter.com/ ) : **TLSv1.2**
2019-05-02 11:03:09 +00:00
- [**My Site** ](https://haka.se/ ) : _TLSv1.3_ **final**
2018-08-22 15:13:33 +00:00
- [Facebook ](https://facebook.com/ ) : _TLSv1.3_ draft 23, 26, 28, **final**
2019-02-09 11:31:04 +00:00
- [Cloudflare ](https://cloudflare.com/ ) : _TLSv1.3_ **final**
- [Google(Gmail) ](https://gmail.com/ ) : _TLSv1.3_ **final**
2018-10-03 06:39:58 +00:00
- [NSS TLS 1.3(Mozilla) ](https://tls13.crypto.mozilla.org/ ) : _TLSv1.3_ **final**
2018-08-17 04:15:58 +00:00
2019-05-02 08:39:20 +00:00
[Compatible OpenSSL-3.0.0-dev (OpenSSL, 23791 commits) ](https://github.com/openssl/openssl/tree/e8fb288cc5057bb198a7f1c6e46f3b64b5d7a476 )
2018-05-09 16:18:49 +00:00
2018-06-04 22:48:56 +00:00
## Patch files
2018-06-01 04:26:27 +00:00
2018-12-07 13:24:47 +00:00
### The equal preference patch(openssl-equal-x) already includes the tls13_draft patch and the tls13_nginx_config(_ciphers file only) patch. Therefore, you do not need to patch it together.
2018-06-08 18:04:08 +00:00
You can find the _OpenSSL 1.1.0h_ patch is [here. ](https://gitlab.com/buik/openssl/blob/openssl-patch/openssl-1.1/OpenSSL1.1h-equal-preference-cipher-groups.patch )
2018-06-01 04:30:38 +00:00
Here is the basic patch content.
2018-06-01 04:26:27 +00:00
- BoringSSL's Equal Preference Patch
2018-06-04 22:48:56 +00:00
- Weak 3DES and not using ECDHE ciphers is not used in TLSv1.1 or later.
2018-06-01 04:26:27 +00:00
| Patch file name | Patch list |
2018-06-04 23:03:41 +00:00
| :--- | :--- |
2018-12-06 13:58:50 +00:00
| openssl-equal-1.1.1a.patch< br > openssl-equal-3.0.0-dev.patch | Support **final (TLS 1.3)** , TLS 1.3 cipher settings **_can not_** be changed on _nginx_ . |
| openssl-equal-1.1.1a_ciphers.patch< br > openssl-equal-3.0.0-dev_ciphers.patch | Support **final (TLS 1.3)** , TLS 1.3 cipher settings **_can_** be changed on _nginx_ . |
| openssl-1.1.1a-chacha_draft.patch< br > openssl-3.0.0-dev-chacha_draft.patch | A draft version of chacha20-poly1305 is available. [View issue ](https://github.com/hakasenyang/openssl-patch/issues/1#issuecomment-427554824 ) |
2019-02-09 11:31:04 +00:00
| openssl-1.1.1a-tls13_draft.patch | Only for **TLS 1.3 draft 23, 26, 28, final support patch** . |
2018-12-03 10:39:13 +00:00
| openssl-1.1.1a-tls13_nginx_config.patch | You can set TLS 1.3 ciphere in nginx. ex) TLS13+AESGCM+AES128 |
2019-04-25 07:50:38 +00:00
| openssl-1.1.1c-prioritize_chacha_draft.patch | Priority applied patch for CHACHA20 and CHACHA20-DRAFT. [View Pull Request ](https://github.com/hakasenyang/openssl-patch/pull/17 ) |
| openssl-3.0.0-session_tls13.patch | For TLS 1.2 and below, the existing session timeout value is written. For TLS 1.3, 172800 (2 days) is fixed. |
2018-12-07 13:41:12 +00:00
| openssl-3.0.0-dev_version_error.patch | **TEST** This is a way to fix nginx when the following errors occur during the build:< br > Error: missing binary operator before token "("< br > Maybe patched: [https://github.com/openssl/openssl/pull/7839 ](https://github.com/openssl/openssl/pull/7839 )< br > Patched : [https://github.com/openssl/openssl/commit/5d609f22d28615c45685d9da871d432e9cb81127 ](https://github.com/openssl/openssl/commit/5d609f22d28615c45685d9da871d432e9cb81127 ) |
2018-10-21 11:52:42 +00:00
2018-06-01 04:30:38 +00:00
**The "_ciphers" patch file is a temporary change to the TLS 1.3 configuration.**
2018-09-13 03:09:47 +00:00
Example of setting TLS 1.3 cipher in nginx:
2018-06-01 04:26:27 +00:00
2018-06-24 12:06:20 +00:00
| Example | Ciphers |
2018-06-05 12:50:07 +00:00
| :--- | :--- |
2018-06-24 12:06:20 +00:00
| Short Cipher | TLS13+AESGCM+AES128:TLS13+AESGCM+AES256:TLS13+CHACHA20 |
| Fullname Cipher | TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 |
| TLS 1.3 + 1.2 ciphers | TLS13+AESGCM+AES128:EECDH+AES128 |
2018-06-05 12:50:07 +00:00
2018-06-24 14:31:13 +00:00
## Not OpenSSL patch files
| Patch file name | Patch list |
| :--- | :--- |
| nginx_hpack_push.patch | _Patch both_ the HPACK patch and the **PUSH ERROR** . |
| nginx_hpack_push_fix.patch | _Patch only_ the **PUSH ERROR** of the hpack patch. (If the HPACK patch has already been completed) |
| remove_nginx_server_header.patch | Remove nginx server header. (http2, http1.1) |
2018-09-03 09:56:48 +00:00
| nginx_hpack_remove_server_header_1.15.3.patch | HPACK + Remove nginx server header. (http2, http1.1) |
2018-09-15 17:33:44 +00:00
| nginx_strict-sni.patch | Enable **Strict-SNI** . Thanks [@JemmyLoveJenny ](https://github.com/JemmyLoveJenny ). [View issue ](https://github.com/hakasenyang/openssl-patch/issues/1#issuecomment-421551872 ) |
2018-10-03 08:37:08 +00:00
| nginx_openssl-1.1.x_renegotiation_bugfix.patch | Bugfix **Secure Client-Initiated Renegotiation** . (Check testssl.sh) OpenSSL >= 1.1.x, nginx = 1.15.4< br > [Patched nginx 1.15.5](https://github.com/nginx/nginx/commit/53803b4780be15d8014be183d4161091fd5f3376) |
2019-04-02 08:06:36 +00:00
| nginx_ocsp.sh | Some of the parts that can not get OCSP Stapling value at nginx start or reload are solved.< br > OCSP stapling in nginx is made up of a callback, so you only need to connect at least once to get the value.< br > This file is a temporary file and may not work normally. |
2018-06-24 14:31:13 +00:00
2018-06-30 08:08:38 +00:00
## How To Use?
### OpenSSL Patch
```
git clone https://github.com/openssl/openssl.git
git clone https://github.com/hakasenyang/openssl-patch.git
cd openssl
2018-12-06 13:58:50 +00:00
patch -p1 < .. / openssl-patch / openssl-equal-3 . 0 . 0-dev_ciphers . patch
2018-06-30 08:08:38 +00:00
```
And then use --with-openssl in nginx or build after ./config.
2018-10-06 10:48:18 +00:00
### OpenSSL CHACHA20-POLY1305-OLD Patch
Thanks [@JemmyLoveJenny ](https://github.com/JemmyLoveJenny )!
[View issue ](https://github.com/hakasenyang/openssl-patch/issues/1#issuecomment-427554824 ) / [Original Source ](https://github.com/JemmyLoveJenny/ngx_ossl_patches/blob/master/ossl_enable_chacha20-poly1305-draft.patch )
```
git clone https://github.com/openssl/openssl.git
git clone https://github.com/hakasenyang/openssl-patch.git
cd openssl
2018-12-03 10:39:13 +00:00
patch -p1 < .. / openssl-patch / openssl-1 . 1 . 1a-chacha_draft . patch
2018-10-06 10:48:18 +00:00
```
2018-06-30 08:08:38 +00:00
### nginx HPACK Patch
Run it from the nginx directory.
If you **have a** PUSH patch, use it as follows.
``curl https://raw.githubusercontent.com/hakasenyang/openssl-patch/master/nginx_hpack_push_fix.patch | patch -p1 ``
If you **did not** patch PUSH, use it as follows.
``curl https://raw.githubusercontent.com/hakasenyang/openssl-patch/master/nginx_hpack_push.patch | patch -p1``
And then check the nginx configuration below.
### nginx Remove Server Header Patch
Run it from the nginx directory.
``curl https://raw.githubusercontent.com/hakasenyang/openssl-patch/master/remove_nginx_server_header.patch | patch -p1``
2018-09-15 17:29:55 +00:00
### nginx strict-sni patch
Run it from the nginx directory.
``curl https://raw.githubusercontent.com/hakasenyang/openssl-patch/master/nginx_strict-sni.patch | patch -p1``
2018-10-07 22:55:07 +00:00
This is a condition for using strict sni. [View issue. ](https://github.com/hakasenyang/openssl-patch/issues/7#issuecomment-427664716 )
2018-10-07 22:43:53 +00:00
2018-10-08 19:41:33 +00:00
- How to use nginx strict-sni?
- **ONLY USE IN http { }**
- strict_sni : nginx strict-sni ON/OFF toggle option.
- strict_sni_header : if you do not want to respond to invalid headers. (**only with strict_sni**)
- Strict SNI requires at least two ssl server (fake) settings (server { listen 443 ssl }).
- It does not matter what kind of certificate or duplicate.
2019-04-03 11:48:59 +00:00
- (>1.15.10) If no SNI is required, print the certificate without applying strict-SNI.
2018-10-08 19:41:33 +00:00
Thanks [@JemmyLoveJenny ](https://github.com/hakasenyang/openssl-patch/issues/1#issuecomment-427040319 ), [@NewBugger ](https://github.com/hakasenyang/openssl-patch/issues/7#issuecomment-427831677 )!
2018-09-15 17:29:55 +00:00
2018-10-03 06:38:31 +00:00
### nginx OpenSSL-1.1.x Renegotiation Bugfix
2018-12-06 13:58:50 +00:00
It has already been patched by nginx >= 1.15.4.
2018-10-03 06:38:31 +00:00
Run it from the nginx directory.
``curl https://raw.githubusercontent.com/hakasenyang/openssl-patch/master/nginx_openssl-1.1.x_renegotiation_bugfix.patch | patch -p1``
2018-06-08 18:10:20 +00:00
## nginx Configuration
2018-05-30 05:45:05 +00:00
2018-06-08 18:10:20 +00:00
### HPACK Patch
2018-06-30 08:08:38 +00:00
Add configure arguments : ``--with-http_v2_hpack_enc``
2018-06-08 18:10:20 +00:00
### SSL Setting
2018-06-01 04:26:27 +00:00
```
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers [Copy it from below and paste it here.];
ssl_ecdh_curve X25519:P-256:P-384;
ssl_prefer_server_ciphers on;
```
2019-02-09 11:31:04 +00:00
### OpenSSL-1.1.1a, 3.0.0-dev ciphers
2018-06-01 04:26:27 +00:00
```
[EECDH+ECDSA+AESGCM+AES128|EECDH+ECDSA+CHACHA20]:EECDH+ECDSA+AESGCM+AES256:EECDH+ECDSA+AES128+SHA:EECDH+ECDSA+AES256+SHA:[EECDH+aRSA+AESGCM+AES128|EECDH+aRSA+CHACHA20]:EECDH+aRSA+AESGCM+AES256:EECDH+aRSA+AES128+SHA:EECDH+aRSA+AES256+SHA:RSA+AES128+SHA:RSA+AES256+SHA:RSA+3DES
```
2018-05-24 14:01:49 +00:00
2019-02-09 11:31:04 +00:00
### OpenSSL-1.1.1a_ciphers, 3.0.0-dev_ciphers ciphers
2018-06-01 04:26:27 +00:00
```
2018-06-04 22:48:56 +00:00
[TLS13+AESGCM+AES128|TLS13+AESGCM+AES256|TLS13+CHACHA20]:[EECDH+ECDSA+AESGCM+AES128|EECDH+ECDSA+CHACHA20]:EECDH+ECDSA+AESGCM+AES256:EECDH+ECDSA+AES128+SHA:EECDH+ECDSA+AES256+SHA:[EECDH+aRSA+AESGCM+AES128|EECDH+aRSA+CHACHA20]:EECDH+aRSA+AESGCM+AES256:EECDH+aRSA+AES128+SHA:EECDH+aRSA+AES256+SHA:RSA+AES128+SHA:RSA+AES256+SHA:RSA+3DES
2018-06-01 04:26:27 +00:00
```
2019-04-03 11:32:41 +00:00
## Other.
### nginx ocsp shell
The configuration file recognizes the ** *.conf** file in ** /etc/nginx**.
Precedence settings in **nginx.conf** are as follows:
worker_processes 1 - **If this number is high, the remaining worker processes do not have OCSP Stapling values.**
After reload or restart, execute the corresponding shell. That's it!
I tried to edit nginx, but I have not found a good way yet. :(