@@ -905,57 +905,31 @@ _get_peer_alt_names (X509 *certificate) {
905905 then iterates through the stack to add the
906906 names. */
907907
908- int i , j ;
908+ int j ;
909909 PyObject * peer_alt_names = Py_None ;
910910 PyObject * v = NULL , * t ;
911- X509_EXTENSION * ext = NULL ;
912911 GENERAL_NAMES * names = NULL ;
913912 GENERAL_NAME * name ;
914- const X509V3_EXT_METHOD * method ;
915913 BIO * biobuf = NULL ;
916914 char buf [2048 ];
917915 char * vptr ;
918916 int len ;
919- const unsigned char * p ;
920917
921918 if (certificate == NULL )
922919 return peer_alt_names ;
923920
924921 /* get a memory buffer */
925922 biobuf = BIO_new (BIO_s_mem ());
926923
927- i = -1 ;
928- while ((i = X509_get_ext_by_NID (
929- certificate , NID_subject_alt_name , i )) >= 0 ) {
930-
924+ names = (GENERAL_NAMES * )X509_get_ext_d2i (
925+ certificate , NID_subject_alt_name , NULL , NULL );
926+ if (names != NULL ) {
931927 if (peer_alt_names == Py_None ) {
932928 peer_alt_names = PyList_New (0 );
933929 if (peer_alt_names == NULL )
934930 goto fail ;
935931 }
936932
937- /* now decode the altName */
938- ext = X509_get_ext (certificate , i );
939- if (!(method = X509V3_EXT_get (ext ))) {
940- PyErr_SetString
941- (PySSLErrorObject ,
942- ERRSTR ("No method for internalizing subjectAltName!" ));
943- goto fail ;
944- }
945-
946- p = X509_EXTENSION_get_data (ext )-> data ;
947- if (method -> it )
948- names = (GENERAL_NAMES * )
949- (ASN1_item_d2i (NULL ,
950- & p ,
951- X509_EXTENSION_get_data (ext )-> length ,
952- ASN1_ITEM_ptr (method -> it )));
953- else
954- names = (GENERAL_NAMES * )
955- (method -> d2i (NULL ,
956- & p ,
957- X509_EXTENSION_get_data (ext )-> length ));
958-
959933 for (j = 0 ; j < sk_GENERAL_NAME_num (names ); j ++ ) {
960934 /* get a rendering of each name in the set of names */
961935 int gntype ;
0 commit comments