xref: /unit/auto/ssltls (revision 1942:296628096d6c)
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) NGINX, Inc.
4
5
6NXT_OPENSSL_CFLAGS=
7NXT_OPENSSL_LIBS=
8NXT_GNUTLS_CFLAGS=
9NXT_GNUTLS_LIBS=
10NXT_OPENSSL_LIBS=
11NXT_CYASSL_CFLAGS=
12NXT_CYASSL_LIBS=
13NXT_POLARSSL_CFLAGS=
14NXT_POLARSSL_LIBS=
15
16
17if [ $NXT_OPENSSL = YES ]; then
18
19    nxt_feature="OpenSSL library"
20    nxt_feature_name=NXT_HAVE_OPENSSL
21    nxt_feature_run=yes
22    nxt_feature_incs=
23    nxt_feature_libs="-lssl -lcrypto"
24    nxt_feature_test="#include <openssl/ssl.h>
25
26                      int main() {
27                          SSL_library_init();
28                          return 0;
29                      }"
30    . auto/feature
31
32
33    if [ $nxt_found = yes ]; then
34        NXT_TLS=YES
35        NXT_OPENSSL_LIBS="$nxt_feature_libs"
36
37        nxt_feature="OpenSSL version"
38        nxt_feature_name=NXT_HAVE_OPENSSL_VERSION
39        nxt_feature_run=value
40        nxt_feature_test="#include <openssl/ssl.h>
41
42                          int main() {
43                              printf(\"\\\"%s\\\"\",
44                                     SSLeay_version(SSLEAY_VERSION));
45                              return 0;
46                          }"
47        . auto/feature
48
49    else
50        $echo
51        $echo $0: error: no OpenSSL library found.
52        $echo
53        exit 1;
54    fi
55
56
57    nxt_feature="OpenSSL SSL_CONF_cmd()"
58    nxt_feature_name=NXT_HAVE_OPENSSL_CONF_CMD
59    nxt_feature_run=
60    nxt_feature_incs=
61    nxt_feature_libs="$NXT_OPENSSL_LIBS"
62    nxt_feature_test="#include <openssl/ssl.h>
63
64                      int main() {
65                          SSL_CONF_cmd(NULL, NULL, NULL);
66                          return 0;
67                      }"
68    . auto/feature
69
70
71    nxt_feature="OpenSSL tlsext support"
72    nxt_feature_name=NXT_HAVE_OPENSSL_TLSEXT
73    nxt_feature_run=
74    nxt_feature_incs=
75    nxt_feature_libs="$NXT_OPENSSL_LIBS"
76    nxt_feature_test="#include <openssl/ssl.h>
77
78                      int main() {
79                          #if (OPENSSL_NO_TLSEXT)
80                          #error OpenSSL: no tlsext support.
81                          #else
82                          return 0;
83                          #endif
84                      }"
85    . auto/feature
86fi
87
88
89if [ $NXT_GNUTLS = YES ]; then
90
91    if /bin/sh -c "(pkg-config gnutls --exists)" >> $NXT_AUTOCONF_ERR 2>&1;
92    then
93        NXT_GNUTLS_CFLAGS=`pkg-config gnutls --cflags`
94        NXT_GNUTLS_LIBS=`pkg-config gnutls --libs`
95
96        nxt_feature="GnuTLS library"
97        nxt_feature_name=NXT_HAVE_GNUTLS
98        nxt_feature_run=yes
99        nxt_feature_incs=$NXT_GNUTLS_CFLAGS
100        nxt_feature_libs=$NXT_GNUTLS_LIBS
101        nxt_feature_test="#include <gnutls/gnutls.h>
102
103                          int main() {
104                              gnutls_global_init();
105                              gnutls_global_deinit();
106                              return 0;
107                          }"
108        . auto/feature
109
110
111        if [ $nxt_found = yes ]; then
112            NXT_TLS=YES
113
114            $echo " + GnuTLS version: `pkg-config gnutls --modversion`"
115
116
117            nxt_feature="gnutls_transport_set_vec_push_function"
118            nxt_feature_name=NXT_HAVE_GNUTLS_VEC_PUSH
119            nxt_feature_run=no
120            nxt_feature_incs=$NXT_GNUTLS_CFLAGS
121            nxt_feature_libs=$NXT_GNUTLS_LIBS
122            nxt_feature_test="#include <gnutls/gnutls.h>
123
124                      int main() {
125                          gnutls_transport_set_vec_push_function(NULL, NULL);
126                          return 0;
127                      }"
128            . auto/feature
129
130
131            nxt_feature="gnutls_global_set_time_function"
132            nxt_feature_name=NXT_HAVE_GNUTLS_SET_TIME
133            nxt_feature_run=no
134            nxt_feature_incs=$NXT_GNUTLS_CFLAGS
135            nxt_feature_libs=$NXT_GNUTLS_LIBS
136            nxt_feature_test="#include <gnutls/gnutls.h>
137
138                      int main() {
139                          gnutls_global_set_time_function(NULL);
140                          return 0;
141                      }"
142            . auto/feature
143
144        else
145            $echo
146            $echo $0: error: no GnuTLS library found.
147            $echo
148            exit 1;
149        fi
150    fi
151fi
152
153
154if [ $NXT_CYASSL = YES ]; then
155
156    nxt_feature="CyaSSL library"
157    nxt_feature_name=NXT_HAVE_CYASSL
158    nxt_feature_run=yes
159    nxt_feature_incs=
160    nxt_feature_libs="-lcyassl"
161    nxt_feature_test="#include <cyassl/ssl.h>
162
163                      int main() {
164                          CyaSSL_Init();
165                          CyaSSL_Cleanup();
166                          return 0;
167                      }"
168    . auto/feature
169
170
171    if [ $nxt_found = yes ]; then
172        NXT_TLS=YES
173        NXT_CYASSL_CFLAGS="$nxt_feature_incs"
174        NXT_CYASSL_LIBS="$nxt_feature_libs"
175
176    else
177        $echo
178        $echo $0: error: no CyaSSL library found.
179        $echo
180        exit 1;
181    fi
182fi
183
184
185if [ $NXT_POLARSSL = YES ]; then
186
187    nxt_feature="PolarSSL library"
188    nxt_feature_name=NXT_HAVE_POLARSSL
189    nxt_feature_run=yes
190    nxt_feature_incs=
191    nxt_feature_libs="-lpolarssl"
192    nxt_feature_test="#include <polarssl/ssl.h>
193
194                      int main() {
195                          ssl_context  ssl;
196                          memset(&ssl, '\0', sizeof(ssl));
197                          ssl_init(&ssl);
198                          ssl_free(&ssl);
199                          return 0;
200                      }"
201    . auto/feature
202
203
204    if [ $nxt_found = yes ]; then
205        NXT_TLS=YES
206        NXT_POLARSSL_CFLAGS="$nxt_feature_incs"
207        NXT_POLARSSL_LIBS="$nxt_feature_libs"
208
209    else
210        $echo
211        $echo $0: error: no PolarSSL library found.
212        $echo
213        exit 1;
214    fi
215fi
216