@@ -4573,50 +4573,6 @@ set_sni_callback(PySSLContext *self, PyObject *arg, void *c)
4573
4573
return 0 ;
4574
4574
}
4575
4575
4576
- #if OPENSSL_VERSION_NUMBER < 0x30300000L
4577
- static X509_OBJECT * x509_object_dup (const X509_OBJECT * obj )
4578
- {
4579
- int ok ;
4580
- X509_OBJECT * ret = X509_OBJECT_new ();
4581
- if (ret == NULL ) {
4582
- return NULL ;
4583
- }
4584
- switch (X509_OBJECT_get_type (obj )) {
4585
- case X509_LU_X509 :
4586
- ok = X509_OBJECT_set1_X509 (ret , X509_OBJECT_get0_X509 (obj ));
4587
- break ;
4588
- case X509_LU_CRL :
4589
- /* X509_OBJECT_get0_X509_CRL was not const-correct prior to 3.0.*/
4590
- ok = X509_OBJECT_set1_X509_CRL (
4591
- ret , X509_OBJECT_get0_X509_CRL ((X509_OBJECT * )obj ));
4592
- break ;
4593
- default :
4594
- /* We cannot duplicate unrecognized types in a polyfill, but it is
4595
- * safe to leave an empty object. The caller will ignore it. */
4596
- ok = 1 ;
4597
- break ;
4598
- }
4599
- if (!ok ) {
4600
- X509_OBJECT_free (ret );
4601
- return NULL ;
4602
- }
4603
- return ret ;
4604
- }
4605
-
4606
- static STACK_OF (X509_OBJECT ) *
4607
- X509_STORE_get1_objects (X509_STORE * store )
4608
- {
4609
- STACK_OF (X509_OBJECT ) * ret ;
4610
- if (!X509_STORE_lock (store )) {
4611
- return NULL ;
4612
- }
4613
- ret = sk_X509_OBJECT_deep_copy (X509_STORE_get0_objects (store ),
4614
- x509_object_dup , X509_OBJECT_free );
4615
- X509_STORE_unlock (store );
4616
- return ret ;
4617
- }
4618
- #endif
4619
-
4620
4576
PyDoc_STRVAR (PySSLContext_sni_callback_doc ,
4621
4577
"Set a callback that will be called when a server name is provided by the SSL/TLS client in the SNI extension.\n\
4622
4578
\n\
@@ -4646,12 +4602,7 @@ _ssl__SSLContext_cert_store_stats_impl(PySSLContext *self)
4646
4602
int x509 = 0 , crl = 0 , ca = 0 , i ;
4647
4603
4648
4604
store = SSL_CTX_get_cert_store (self -> ctx );
4649
- objs = X509_STORE_get1_objects (store );
4650
- if (objs == NULL ) {
4651
- PyErr_SetString (PyExc_MemoryError , "failed to query cert store" );
4652
- return NULL ;
4653
- }
4654
-
4605
+ objs = X509_STORE_get0_objects (store );
4655
4606
for (i = 0 ; i < sk_X509_OBJECT_num (objs ); i ++ ) {
4656
4607
obj = sk_X509_OBJECT_value (objs , i );
4657
4608
switch (X509_OBJECT_get_type (obj )) {
@@ -4665,11 +4616,12 @@ _ssl__SSLContext_cert_store_stats_impl(PySSLContext *self)
4665
4616
crl ++ ;
4666
4617
break ;
4667
4618
default :
4668
- /* Ignore unrecognized types. */
4619
+ /* Ignore X509_LU_FAIL, X509_LU_RETRY, X509_LU_PKEY.
4620
+ * As far as I can tell they are internal states and never
4621
+ * stored in a cert store */
4669
4622
break ;
4670
4623
}
4671
4624
}
4672
- sk_X509_OBJECT_pop_free (objs , X509_OBJECT_free );
4673
4625
return Py_BuildValue ("{sisisi}" , "x509" , x509 , "crl" , crl ,
4674
4626
"x509_ca" , ca );
4675
4627
}
@@ -4701,12 +4653,7 @@ _ssl__SSLContext_get_ca_certs_impl(PySSLContext *self, int binary_form)
4701
4653
}
4702
4654
4703
4655
store = SSL_CTX_get_cert_store (self -> ctx );
4704
- objs = X509_STORE_get1_objects (store );
4705
- if (objs == NULL ) {
4706
- PyErr_SetString (PyExc_MemoryError , "failed to query cert store" );
4707
- goto error ;
4708
- }
4709
-
4656
+ objs = X509_STORE_get0_objects (store );
4710
4657
for (i = 0 ; i < sk_X509_OBJECT_num (objs ); i ++ ) {
4711
4658
X509_OBJECT * obj ;
4712
4659
X509 * cert ;
@@ -4734,11 +4681,9 @@ _ssl__SSLContext_get_ca_certs_impl(PySSLContext *self, int binary_form)
4734
4681
}
4735
4682
Py_CLEAR (ci );
4736
4683
}
4737
- sk_X509_OBJECT_pop_free (objs , X509_OBJECT_free );
4738
4684
return rlist ;
4739
4685
4740
4686
error :
4741
- sk_X509_OBJECT_pop_free (objs , X509_OBJECT_free );
4742
4687
Py_XDECREF (ci );
4743
4688
Py_XDECREF (rlist );
4744
4689
return NULL ;
0 commit comments