OSSP CVS Repository

ossp - Check-in [2858]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2858
Date: 2002-Nov-19 23:30:07 (local)
2002-Nov-19 22:30:07 (UTC)
User:mlelstv
Branch:
Comment: use BIO_f_ssl as source/sink on top of sa socket

PR: Submitted by: Reviewed by: Approved by: Obtained from:

Tickets:
Inspections:
Files:
ossp-pkg/sio/sio_test.c      1.3 -> 1.4     21 inserted, 5 deleted

ossp-pkg/sio/sio_test.c 1.3 -> 1.4

--- sio_test.c   2002/11/19 15:54:51     1.3
+++ sio_test.c   2002/11/19 22:30:07     1.4
@@ -14,9 +14,13 @@
 
 #define e(f) rc = f; printf("%s = %s\n",#f, sio_error(rc)); fflush(stdout);
 #define s(f) src = f; printf("%s = %s\n",#f, sa_error(src)); fflush(stdout);
+#define n(f) rn = f; printf("%s = %d\n",#f, rn); fflush(stdout);
+#define p(f) rp = f; printf("%s = %p\n",#f, rp); fflush(stdout);
 
 int main(int argc, char *argv[])
 {
+    int rn;
+    void *rp;
     sio_rc_t rc;
     sio_t *sio;
     sio_stage_t *sios_bio, *sios_hello, *sios_buffer;
@@ -27,7 +31,8 @@
     char *uri;
 
     int fd;
-    BIO *bio;
+    SSL_CTX *ctx;
+    BIO *bio, *sbio;
 
     char buf[] = "Hello world\n";
 
@@ -44,6 +49,12 @@
     s(sa_addr_destroy(saa));
     uri = NULL;
 
+    OpenSSL_add_ssl_algorithms();
+    ctx = SSL_CTX_new(SSLv23_server_method());
+
+    SSL_CTX_use_certificate_file(ctx, "/u/mlelstv/ssl/server.crt", SSL_FILETYPE_PEM);
+    SSL_CTX_use_PrivateKey_file(ctx, "/u/mlelstv/ssl/server.key", SSL_FILETYPE_PEM);
+
     e(sio_create(&sio));
     e(sio_create_stage(sio, &sio_module_bio, &sios_bio));
     e(sio_create_stage(sio, &sio_module_hello, &sios_hello));
@@ -64,12 +75,13 @@
         printf("Connection from %s\n",uri);
         s(sa_addr_destroy(saa));
 
+        s(sa_getfd(sa, &fd));
+        p(bio = BIO_new_socket(fd, 0));
 
-        bio = BIO_new(BIO_s_socket());
-        sa_getfd(sa, &fd);
-        BIO_set_fd(bio, fd, 0);
+        p(sbio = BIO_new_ssl(ctx,0));
+        p(BIO_push(sbio,bio));
 
-        e(sio_configure_stage(sio, sios_bio, "bio", bio));
+        e(sio_configure_stage(sio, sios_bio, "bio", sbio));
 
         e(sio_attach(sio, sios_buffer, SIO_MODE_WRITE));
         e(sio_attach(sio, sios_hello, SIO_MODE_READWRITE));
@@ -82,6 +94,10 @@
         e(sio_detach(sio, sios_hello));
         e(sio_detach(sio, sios_buffer));
 
+        BIO_pop(bio);
+        BIO_free(sbio);
+        BIO_free(bio);
+
         sa_destroy(sa);
     }
 

CVSTrac 2.0.1