You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
3.0 KiB

8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /******************************************************************
  2. * $Id: nanohttp-ssl.h,v 1.18 2006/05/15 06:40:47 m0gg Exp $
  3. *
  4. * CSOAP Project: A http client/server library in C
  5. * Copyright (C) 2001-2005 Rochester Institute of Technology
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. *
  22. * Author: Matt Campbell
  23. ******************************************************************/
  24. #ifndef __NANOHTTP_SSL_H_
  25. #define __NANOHTTP_SSL_H_
  26. #ifdef HAVE_CONFIG_H
  27. #include <config.h>
  28. #endif
  29. #ifdef HAVE_SSL
  30. #ifdef HAVE_OPENSSL_SSL_H
  31. #include <openssl/ssl.h>
  32. #endif
  33. #ifdef __cplusplus
  34. extern "C"
  35. {
  36. #endif
  37. /**
  38. *
  39. * Initialization and shutdown of the SSL module
  40. *
  41. */
  42. herror_t hssl_module_init(int argc, char **argv);
  43. void hssl_module_destroy(void);
  44. void hssl_set_certificate(char *c);
  45. void hssl_set_certpass(char *c);
  46. void hssl_set_ca(char *c);
  47. void hssl_enable(void);
  48. int hssl_enabled(void);
  49. /**
  50. *
  51. * Socket initialization and shutdown
  52. *
  53. */
  54. herror_t hssl_client_ssl(hsocket_t * sock);
  55. herror_t hssl_server_ssl(hsocket_t * sock);
  56. void hssl_cleanup(hsocket_t * sock);
  57. /*
  58. * Callback for password checker
  59. */
  60. /* static int pw_cb(char* buf, int num, int rwflag, void *userdata); */
  61. /*
  62. * Quick function for verifying a portion of the cert
  63. * nid is any NID_ defined in <openssl/objects.h>
  64. * returns non-zero if everything went ok
  65. */
  66. #define CERT_SUBJECT 1
  67. int verify_sn(X509 * cert, int who, int nid, char *str);
  68. /*
  69. * Called by framework for verify
  70. */
  71. /* static int verify_cb(int prev_ok, X509_STORE_CTX* ctx); */
  72. void hssl_set_user_verify(int func(X509 * cert));
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #else /* HAVE_SSL */
  77. static inline herror_t
  78. hssl_module_init(int argc, char **argv)
  79. {
  80. return H_OK;
  81. }
  82. static inline void
  83. hssl_module_destroy(void)
  84. {
  85. return;
  86. }
  87. static inline int
  88. hssl_enabled(void)
  89. {
  90. return 0;
  91. }
  92. static inline herror_t
  93. hssl_client_ssl(hsocket_t * sock)
  94. {
  95. return H_OK;
  96. }
  97. static inline herror_t
  98. hssl_server_ssl(hsocket_t * sock)
  99. {
  100. return H_OK;
  101. }
  102. static inline void
  103. hssl_cleanup(hsocket_t * sock)
  104. {
  105. return;
  106. }
  107. #endif /* HAVE_SSL */
  108. #ifdef __cplusplus
  109. extern "C"
  110. {
  111. #endif
  112. herror_t hssl_read(hsocket_t * sock, char *buf, size_t len,
  113. size_t * received);
  114. herror_t hssl_write(hsocket_t * sock, const char *buf, size_t len,
  115. size_t * sent);
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119. #endif