c - 使用 OpenSSL 的 Web 服务器

标签 c linux ssl tcp

我正在尝试编译我的网络服务器,但发生了如下情况:

gcc -o webserv.o webserv.c -c -ansi -pedantic -Wall -lssl -lcrypto
webserv.c: In function ‘main’:
webserv.c:33: warning: ‘OPENSSL_add_all_algorithms_noconf’ is deprecated (declared at /usr/include/openssl/evp.h:828)
webserv.c:34: warning: ‘SSL_load_error_strings’ is deprecated (declared at /usr/include/openssl/ssl.h:1416)
webserv.c:36: warning: ‘TLSv1_server_method’ is deprecated (declared at /usr/include/openssl/ssl.h:1520)
webserv.c:38: warning: ‘SSL_CTX_new’ is deprecated (declared at /usr/include/openssl/ssl.h:1346)
webserv.c:40: warning: ‘ERR_print_errors_fp’ is deprecated (declared at /usr/include/openssl/err.h:287)
webserv.c:44: warning: ‘SSL_CTX_use_certificate_file’ is deprecated (declared at /usr/include/openssl/ssl.h:1402)
webserv.c:45: warning: ‘SSL_CTX_use_PrivateKey_file’ is deprecated (declared at /usr/include/openssl/ssl.h:1401)
webserv.c:47: warning: ‘SSL_CTX_check_private_key’ is deprecated (declared at /usr/include/openssl/ssl.h:1475)
webserv.c:92: warning: ‘SSL_new’ is deprecated (declared at /usr/include/openssl/ssl.h:1481)
webserv.c:94: warning: ‘ERR_print_errors_fp’ is deprecated (declared at /usr/include/openssl/err.h:287)
webserv.c:98: warning: ‘SSL_set_fd’ is deprecated (declared at /usr/include/openssl/ssl.h:1370)
webserv.c:100: warning: ‘SSL_accept’ is deprecated (declared at /usr/include/openssl/ssl.h:1491)
webserv.c:102: warning: ‘ERR_print_errors_fp’ is deprecated (declared at /usr/include/openssl/err.h:287)
webserv.c:106: warning: ‘SSL_get_version’ is deprecated (declared at /usr/include/openssl/ssl.h:1502)
webserv.c:106: warning: ‘SSL_CIPHER_get_name’ is deprecated (declared at /usr/include/openssl/ssl.h:1360)
webserv.c:106: warning: ‘SSL_get_current_cipher’ is deprecated (declared at /usr/include/openssl/ssl.h:1357)
webserv.c:114: warning: ‘SSL_shutdown’ is deprecated (declared at /usr/include/openssl/ssl.h:1532)
webserv.c:116: warning: ‘SSL_free’ is deprecated (declared at /usr/include/openssl/ssl.h:1490)
i686-apple-darwin11-llvm-gcc-4.2: -lssl: linker input file unused because linking not done
i686-apple-darwin11-llvm-gcc-4.2: -lcrypto: linker input file unused because linking not done
gcc -o helper.o helper.c -c -ansi -pedantic -Wall -lssl -lcrypto
helper.c: In function ‘Readline’:
helper.c:32: warning: ‘SSL_read’ is deprecated (declared at /usr/include/openssl/ssl.h:1493)
helper.c: In function ‘Writeline’:
helper.c:68: warning: ‘SSL_write’ is deprecated (declared at /usr/include/openssl/ssl.h:1495)
i686-apple-darwin11-llvm-gcc-4.2: -lssl: linker input file unused because linking not done
i686-apple-darwin11-llvm-gcc-4.2: -lcrypto: linker input file unused because linking not done
gcc -o servreq.o servreq.c -c -ansi -pedantic -Wall -lssl -lcrypto
i686-apple-darwin11-llvm-gcc-4.2: -lssl: linker input file unused because linking not done
i686-apple-darwin11-llvm-gcc-4.2: -lcrypto: linker input file unused because linking not done
gcc -o reqhead.o reqhead.c -c -ansi -pedantic -Wall -lssl -lcrypto
i686-apple-darwin11-llvm-gcc-4.2: -lssl: linker input file unused because linking not done
i686-apple-darwin11-llvm-gcc-4.2: -lcrypto: linker input file unused because linking not done
gcc -o resphead.o resphead.c -c -ansi -pedantic -Wall -lssl -lcrypto
i686-apple-darwin11-llvm-gcc-4.2: -lssl: linker input file unused because linking not done
i686-apple-darwin11-llvm-gcc-4.2: -lcrypto: linker input file unused because linking not done
gcc -o resource.o resource.c -c -ansi -pedantic -Wall -lssl -lcrypto
i686-apple-darwin11-llvm-gcc-4.2: -lssl: linker input file unused because linking not done
i686-apple-darwin11-llvm-gcc-4.2: -lcrypto: linker input file unused because linking not done
gcc -o webserv webserv.o helper.o servreq.o reqhead.o resphead.o resource.o -Wall -lssl -lcrypto
Undefined symbols for architecture x86_64:
  "_server_ssl", referenced from:
      _Readline in helper.o
      _Writeline in helper.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

有人知道这里出了什么问题吗?

最佳答案

在我看来,您的编译器设置为在出现警告时中止链接,并且编译阶段在您的代码中生成了数十个“弃用”警告。因此,您可以选择更改编译器标志或更新已弃用的调用。

关于c - 使用 OpenSSL 的 Web 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10560380/

相关文章:

ruby-on-rails - 是否已成功安装 action_mailer_optional_tls 以使用 GMail 发送?

c# - 通过 https 调用 W2008R2 上托管的 wcf rest api 可以从 W7 但不能从 W10

php - 即使禁用 VERIFYPEER、VERIFYHOST 也会出现 SSL 连接错误

c - 如何修复 "recursively print subdirectories in c"

c - 如何用C语言更改浏览目录

linux - makefile 没有正确导入 PATH

c - 如何指定在支持 2 个不同设备的驱动程序中打开哪个设备?

c - 为什么 `scanf()` 函数将 %s 和 %c 视为同一类型?

检查 char 是否以\xHH 表示法写入

c++ - 为什么会出现此错误? void* 不是指向对象类型的指针。