xref: /unit/auto/ssltls (revision 1885:09b857a2cca9)
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
69fi
70
71
72if [ $NXT_GNUTLS = YES ]; then
73
74    if /bin/sh -c "(pkg-config gnutls --exists)" >> $NXT_AUTOCONF_ERR 2>&1;
75    then
76        NXT_GNUTLS_CFLAGS=`pkg-config gnutls --cflags`
77        NXT_GNUTLS_LIBS=`pkg-config gnutls --libs`
78
79        nxt_feature="GnuTLS library"
80        nxt_feature_name=NXT_HAVE_GNUTLS
81        nxt_feature_run=yes
82        nxt_feature_incs=$NXT_GNUTLS_CFLAGS
83        nxt_feature_libs=$NXT_GNUTLS_LIBS
84        nxt_feature_test="#include <gnutls/gnutls.h>
85
86                          int main() {
87                              gnutls_global_init();
88                              gnutls_global_deinit();
89                              return 0;
90                          }"
91        . auto/feature
92
93
94        if [ $nxt_found = yes ]; then
95            NXT_TLS=YES
96
97            $echo " + GnuTLS version: `pkg-config gnutls --modversion`"
98
99
100            nxt_feature="gnutls_transport_set_vec_push_function"
101            nxt_feature_name=NXT_HAVE_GNUTLS_VEC_PUSH
102            nxt_feature_run=no
103            nxt_feature_incs=$NXT_GNUTLS_CFLAGS
104            nxt_feature_libs=$NXT_GNUTLS_LIBS
105            nxt_feature_test="#include <gnutls/gnutls.h>
106
107                      int main() {
108                          gnutls_transport_set_vec_push_function(NULL, NULL);
109                          return 0;
110                      }"
111            . auto/feature
112
113
114            nxt_feature="gnutls_global_set_time_function"
115            nxt_feature_name=NXT_HAVE_GNUTLS_SET_TIME
116            nxt_feature_run=no
117            nxt_feature_incs=$NXT_GNUTLS_CFLAGS
118            nxt_feature_libs=$NXT_GNUTLS_LIBS
119            nxt_feature_test="#include <gnutls/gnutls.h>
120
121                      int main() {
122                          gnutls_global_set_time_function(NULL);
123                          return 0;
124                      }"
125            . auto/feature
126
127        else
128            $echo
129            $echo $0: error: no GnuTLS library found.
130            $echo
131            exit 1;
132        fi
133    fi
134fi
135
136
137if [ $NXT_CYASSL = YES ]; then
138
139    nxt_feature="CyaSSL library"
140    nxt_feature_name=NXT_HAVE_CYASSL
141    nxt_feature_run=yes
142    nxt_feature_incs=
143    nxt_feature_libs="-lcyassl"
144    nxt_feature_test="#include <cyassl/ssl.h>
145
146                      int main() {
147                          CyaSSL_Init();
148                          CyaSSL_Cleanup();
149                          return 0;
150                      }"
151    . auto/feature
152
153
154    if [ $nxt_found = yes ]; then
155        NXT_TLS=YES
156        NXT_CYASSL_CFLAGS="$nxt_feature_incs"
157        NXT_CYASSL_LIBS="$nxt_feature_libs"
158
159    else
160        $echo
161        $echo $0: error: no CyaSSL library found.
162        $echo
163        exit 1;
164    fi
165fi
166
167
168if [ $NXT_POLARSSL = YES ]; then
169
170    nxt_feature="PolarSSL library"
171    nxt_feature_name=NXT_HAVE_POLARSSL
172    nxt_feature_run=yes
173    nxt_feature_incs=
174    nxt_feature_libs="-lpolarssl"
175    nxt_feature_test="#include <polarssl/ssl.h>
176
177                      int main() {
178                          ssl_context  ssl;
179                          memset(&ssl, '\0', sizeof(ssl));
180                          ssl_init(&ssl);
181                          ssl_free(&ssl);
182                          return 0;
183                      }"
184    . auto/feature
185
186
187    if [ $nxt_found = yes ]; then
188        NXT_TLS=YES
189        NXT_POLARSSL_CFLAGS="$nxt_feature_incs"
190        NXT_POLARSSL_LIBS="$nxt_feature_libs"
191
192    else
193        $echo
194        $echo $0: error: no PolarSSL library found.
195        $echo
196        exit 1;
197    fi
198fi
199