1 --- a/src/ptclib/pssl.cxx 2017-03-28 14:35:23.261060113 +0200
2 +++ b/src/ptclib/pssl.cxx 2017-03-28 14:30:20.593853443 +0200
7 - PSSL_BIO(BIO_METHOD *method = BIO_s_file_internal())
8 + PSSL_BIO(const BIO_METHOD *method = BIO_s_file())
9 { bio = BIO_new(method); }
16 - dh->p = BN_bin2bn(pData, pSize, NULL);
17 - dh->g = BN_bin2bn(gData, gSize, NULL);
18 - if (dh->p != NULL && dh->g != NULL)
19 + BIGNUM *p = BN_bin2bn(pData, pSize, NULL);
20 + BIGNUM *g = BN_bin2bn(gData, gSize, NULL);
21 + DH_set0_pqg(dh, p, NULL, g);
22 + if (p != NULL && p != NULL)
30 -#define PSSLCHANNEL(bio) ((PSSLChannel *)(bio->ptr))
31 +#define PSSLCHANNEL(bio) ((PSSLChannel *)BIO_get_data(bio))
35 @@ -1128,10 +1129,9 @@
37 static int Psock_new(BIO * bio)
41 - bio->ptr = NULL; // this is really (PSSLChannel *)
43 + BIO_set_init(bio, 0);
44 + BIO_set_data(bio, NULL);
45 + BIO_clear_flags(bio, ~0);
49 @@ -1142,13 +1142,13 @@
53 - if (bio->shutdown) {
55 + if (BIO_get_shutdown(bio)) {
56 + if (BIO_get_init(bio)) {
57 PSSLCHANNEL(bio)->Shutdown(PSocket::ShutdownReadAndWrite);
58 PSSLCHANNEL(bio)->Close();
62 + BIO_set_init(bio, 0);
63 + BIO_clear_flags(bio, ~0);
67 @@ -1158,11 +1158,11 @@
70 case BIO_CTRL_SET_CLOSE:
71 - bio->shutdown = (int)num;
72 + BIO_set_shutdown(bio, (int)num);
75 case BIO_CTRL_GET_CLOSE:
76 - return bio->shutdown;
77 + return BIO_get_shutdown(bio);
85 -static BIO_METHOD methods_Psock =
86 +static BIO_METHOD *methods_Psock = NULL;
91 @@ -1259,19 +1260,33 @@
98 PBoolean PSSLChannel::OnOpen()
100 - BIO * bio = BIO_new(&methods_Psock);
101 + if (methods_Psock == NULL) {
102 + methods_Psock = BIO_meth_new(BIO_TYPE_SOCKET | BIO_get_new_index(), "PTLib-PSSLChannel");
103 + if (methods_Psock == NULL ||
104 + BIO_meth_set_write(methods_Psock, Psock_write) ||
105 + BIO_meth_set_read(methods_Psock, Psock_read) ||
106 + BIO_meth_set_puts(methods_Psock, Psock_puts) ||
107 + BIO_meth_set_gets(methods_Psock, NULL) ||
108 + BIO_meth_set_ctrl(methods_Psock, Psock_ctrl) ||
109 + BIO_meth_set_create(methods_Psock, Psock_new) ||
110 + BIO_meth_set_destroy(methods_Psock, Psock_free)) {
111 + SSLerr(SSL_F_SSL_SET_FD,ERR_R_BUF_LIB);
115 + BIO * bio = BIO_new(methods_Psock);
117 SSLerr(SSL_F_SSL_SET_FD,ERR_R_BUF_LIB);
124 + BIO_set_data(bio, this);
125 + BIO_set_init(bio, 1);
127 SSL_set_bio(ssl, bio, bio);