@@ -156,10 +156,14 @@ int git_openssl_set_locking(void)
156156
157157static int bio_create (BIO * b )
158158{
159+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
159160 b -> init = 1 ;
160161 b -> num = 0 ;
161162 b -> ptr = NULL ;
162163 b -> flags = 0 ;
164+ #else
165+ BIO_set_init (b , 1 );
166+ #endif
163167
164168 return 1 ;
165169}
@@ -169,23 +173,36 @@ static int bio_destroy(BIO *b)
169173 if (!b )
170174 return 0 ;
171175
176+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
172177 b -> init = 0 ;
173178 b -> num = 0 ;
174179 b -> ptr = NULL ;
175180 b -> flags = 0 ;
181+ #else
182+ BIO_set_init (b , 0 );
183+ BIO_set_data (b , NULL );
184+ #endif
176185
177186 return 1 ;
178187}
179188
180189static int bio_read (BIO * b , char * buf , int len )
181190{
191+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
182192 git_stream * io = (git_stream * ) b -> ptr ;
193+ #else
194+ git_stream * io = (git_stream * ) BIO_get_data (b );
195+ #endif
183196 return (int ) git_stream_read (io , buf , len );
184197}
185198
186199static int bio_write (BIO * b , const char * buf , int len )
187200{
201+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
188202 git_stream * io = (git_stream * ) b -> ptr ;
203+ #else
204+ git_stream * io = (git_stream * ) BIO_get_data (b );
205+ #endif
189206 return (int ) git_stream_write (io , buf , len , 0 );
190207}
191208
@@ -214,6 +231,7 @@ static int bio_puts(BIO *b, const char *str)
214231 return bio_write (b , str , strlen (str ));
215232}
216233
234+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
217235static BIO_METHOD git_stream_bio_method = {
218236 BIO_TYPE_SOURCE_SINK ,
219237 "git_stream" ,
@@ -225,6 +243,9 @@ static BIO_METHOD git_stream_bio_method = {
225243 bio_create ,
226244 bio_destroy
227245};
246+ #else
247+ static BIO_METHOD * git_stream_bio_method = NULL ;
248+ #endif
228249
229250static int ssl_set_error (SSL * ssl , int error )
230251{
@@ -445,9 +466,25 @@ int openssl_connect(git_stream *stream)
445466
446467 st -> connected = true;
447468
469+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
448470 bio = BIO_new (& git_stream_bio_method );
471+ #else
472+ git_stream_bio_method = BIO_meth_new (BIO_TYPE_SOURCE_SINK | BIO_get_new_index (), "git_stream" );
473+ BIO_meth_set_write (git_stream_bio_method , bio_write );
474+ BIO_meth_set_read (git_stream_bio_method , bio_read );
475+ BIO_meth_set_puts (git_stream_bio_method , bio_puts );
476+ BIO_meth_set_gets (git_stream_bio_method , bio_gets );
477+ BIO_meth_set_ctrl (git_stream_bio_method , bio_ctrl );
478+ BIO_meth_set_create (git_stream_bio_method , bio_create );
479+ BIO_meth_set_destroy (git_stream_bio_method , bio_destroy );
480+ bio = BIO_new (git_stream_bio_method );
481+ #endif
449482 GITERR_CHECK_ALLOC (bio );
483+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
450484 bio -> ptr = st -> io ;
485+ #else
486+ BIO_set_data (bio , st -> io );
487+ #endif
451488
452489 SSL_set_bio (st -> ssl , bio , bio );
453490 /* specify the host in case SNI is needed */
0 commit comments