nxt_polarssl.c (0:a63ceefd6ab0) nxt_polarssl.c (564:762f8c976ead)
1
2/*
3 * Copyright (C) NGINX, Inc.
4 * Copyright (C) Igor Sysoev
5 */
6
7#include <nxt_main.h>
8#include <polarssl/config.h>

--- 35 unchanged lines hidden (view full) ---

44
45 ctx = nxt_zalloc(sizeof(nxt_polarssl_ctx_t));
46 if (ctx == NULL) {
47 return NXT_ERROR;
48 }
49
50 n = ssl_init(&ctx->ssl);
51 if (n != 0) {
1
2/*
3 * Copyright (C) NGINX, Inc.
4 * Copyright (C) Igor Sysoev
5 */
6
7#include <nxt_main.h>
8#include <polarssl/config.h>

--- 35 unchanged lines hidden (view full) ---

44
45 ctx = nxt_zalloc(sizeof(nxt_polarssl_ctx_t));
46 if (ctx == NULL) {
47 return NXT_ERROR;
48 }
49
50 n = ssl_init(&ctx->ssl);
51 if (n != 0) {
52 nxt_polarssl_log_error(NXT_LOG_CRIT, thr->log, n, "ssl_init() failed");
52 nxt_polarssl_log_error(NXT_LOG_ALERT, thr->log, n, "ssl_init() failed");
53 return NXT_ERROR;
54 }
55
56 ssl_set_endpoint(&ctx->ssl, SSL_IS_SERVER );
57
58 conf->ctx = ctx;
59 conf->conn_init = nxt_polarssl_conn_init;
60
61 n = x509parse_crtfile(&ctx->certificate, conf->certificate);
62 if (n != 0) {
53 return NXT_ERROR;
54 }
55
56 ssl_set_endpoint(&ctx->ssl, SSL_IS_SERVER );
57
58 conf->ctx = ctx;
59 conf->conn_init = nxt_polarssl_conn_init;
60
61 n = x509parse_crtfile(&ctx->certificate, conf->certificate);
62 if (n != 0) {
63 nxt_polarssl_log_error(NXT_LOG_CRIT, thr->log, n,
63 nxt_polarssl_log_error(NXT_LOG_ALERT, thr->log, n,
64 "x509parse_crt(\"%V\") failed",
65 &conf->certificate);
66 goto fail;
67 }
68
69 rsa_init(&ctx->key, RSA_PKCS_V15, 0);
70
71 n = x509parse_keyfile(&ctx->key, conf->certificate_key, NULL);
72 if (n != 0) {
64 "x509parse_crt(\"%V\") failed",
65 &conf->certificate);
66 goto fail;
67 }
68
69 rsa_init(&ctx->key, RSA_PKCS_V15, 0);
70
71 n = x509parse_keyfile(&ctx->key, conf->certificate_key, NULL);
72 if (n != 0) {
73 nxt_polarssl_log_error(NXT_LOG_CRIT, thr->log, n,
73 nxt_polarssl_log_error(NXT_LOG_ALERT, thr->log, n,
74 "x509parse_key(\"%V\") failed",
75 &conf->certificate_key);
76 goto fail;
77 }
78
79 ssl_set_own_cert(&ctx->ssl, &ctx->certificate, &ctx->key);
80
81 /* TODO: ciphers */

--- 37 unchanged lines hidden ---
74 "x509parse_key(\"%V\") failed",
75 &conf->certificate_key);
76 goto fail;
77 }
78
79 ssl_set_own_cert(&ctx->ssl, &ctx->certificate, &ctx->key);
80
81 /* TODO: ciphers */

--- 37 unchanged lines hidden ---