summaryrefslogtreecommitdiffhomepage
path: root/src/event/ngx_event_openssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/event/ngx_event_openssl.c')
-rw-r--r--src/event/ngx_event_openssl.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
index 3730377aa..b9ccf7631 100644
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -3294,6 +3294,90 @@ ngx_ssl_get_cipher_name(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
ngx_int_t
+ngx_ssl_get_ciphers(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
+{
+#ifdef SSL_CTRL_GET_RAW_CIPHERLIST
+
+ int n, i, bytes;
+ size_t len;
+ u_char *ciphers, *p;
+ const SSL_CIPHER *cipher;
+
+ bytes = SSL_get0_raw_cipherlist(c->ssl->connection, NULL);
+ n = SSL_get0_raw_cipherlist(c->ssl->connection, &ciphers);
+
+ if (n <= 0) {
+ s->len = 0;
+ return NGX_OK;
+ }
+
+ len = 0;
+ n /= bytes;
+
+ for (i = 0; i < n; i++) {
+ cipher = SSL_CIPHER_find(c->ssl->connection, ciphers + i * bytes);
+
+ if (cipher) {
+ len += ngx_strlen(SSL_CIPHER_get_name(cipher));
+
+ } else {
+ len += sizeof("0x") - 1 + bytes * (sizeof("00") - 1);
+ }
+
+ len += sizeof(":") - 1;
+ }
+
+ s->data = ngx_pnalloc(pool, len);
+ if (s->data == NULL) {
+ return NGX_ERROR;
+ }
+
+ p = s->data;
+
+ for (i = 0; i < n; i++) {
+ cipher = SSL_CIPHER_find(c->ssl->connection, ciphers + i * bytes);
+
+ if (cipher) {
+ p = ngx_sprintf(p, "%s", SSL_CIPHER_get_name(cipher));
+
+ } else {
+ p = ngx_sprintf(p, "0x");
+ p = ngx_hex_dump(p, ciphers + i * bytes, bytes);
+ }
+
+ *p++ = ':';
+ }
+
+ p--;
+
+ s->len = p - s->data;
+
+#else
+
+ u_char buf[4096];
+
+ if (SSL_get_shared_ciphers(c->ssl->connection, (char *) buf, 4096)
+ == NULL)
+ {
+ s->len = 0;
+ return NGX_OK;
+ }
+
+ s->len = ngx_strlen(buf);
+ s->data = ngx_pnalloc(pool, s->len);
+ if (s->data == NULL) {
+ return NGX_ERROR;
+ }
+
+ ngx_memcpy(s->data, buf, s->len);
+
+#endif
+
+ return NGX_OK;
+}
+
+
+ngx_int_t
ngx_ssl_get_session_id(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
{
u_char *buf;