~myers-1/pyopenssl/npn

« back to all changes in this revision

Viewing changes to src/ssl/connection.c

  • Committer: Jean-Paul Calderone
  • Date: 2010-01-25 22:55:30 UTC
  • mfrom: (126 trunk)
  • mto: This revision was merged to the branch mainline in revision 129.
  • Revision ID: exarkun@divmod.com-20100125225530-5e9nsb6bzoesoz42
merge trunk and resolve simple conflict

Show diffs side-by-side

added added

removed removed

Lines of Context:
829
829
    return lst;
830
830
}
831
831
 
 
832
static char ssl_Connection_get_client_ca_list_doc[] = "\n\
 
833
Get CAs whose certificates are suggested for client authentication.\n\
 
834
\n\
 
835
@return: If this is a server connection, a list of X509Names representing\n\
 
836
    the acceptable CAs as set by L{OpenSSL.SSL.Context.set_client_ca_list} or\n\
 
837
    L{OpenSSL.SSL.Context.add_client_ca}.  If this is a client connection,\n\
 
838
    the list of such X509Names sent by the server, or an empty list if that\n\
 
839
    has not yet happened.\n\
 
840
";
 
841
 
 
842
static PyObject *
 
843
ssl_Connection_get_client_ca_list(ssl_ConnectionObj *self, PyObject *args) {
 
844
    STACK_OF(X509_NAME) *CANames;
 
845
    PyObject *CAList;
 
846
    int i, n;
 
847
 
 
848
    if (!PyArg_ParseTuple(args, ":get_client_ca_list")) {
 
849
        return NULL;
 
850
    }
 
851
    CANames = SSL_get_client_CA_list(self->ssl);
 
852
    if (CANames == NULL) {
 
853
        return PyList_New(0);
 
854
    }
 
855
    n = sk_X509_NAME_num(CANames);
 
856
    CAList = PyList_New(n);
 
857
    if (CAList == NULL) {
 
858
        return NULL;
 
859
    }
 
860
    for (i = 0; i < n; i++) {
 
861
        X509_NAME *CAName;
 
862
        PyObject *CA;
 
863
 
 
864
        CAName = X509_NAME_dup(sk_X509_NAME_value(CANames, i));
 
865
        if (CAName == NULL) {
 
866
            Py_DECREF(CAList);
 
867
            exception_from_error_queue(ssl_Error);
 
868
            return NULL;
 
869
        }
 
870
        CA = (PyObject *)crypto_X509Name_New(CAName, 1);
 
871
        if (CA == NULL) {
 
872
            X509_NAME_free(CAName);
 
873
            Py_DECREF(CAList);
 
874
            return NULL;
 
875
        }
 
876
        if (PyList_SetItem(CAList, i, CA)) {
 
877
            Py_DECREF(CA);
 
878
            Py_DECREF(CAList);
 
879
            return NULL;
 
880
        }
 
881
    }
 
882
    return CAList;
 
883
}
 
884
 
832
885
static char ssl_Connection_makefile_doc[] = "\n\
833
886
The makefile() method is not implemented, since there is no dup semantics\n\
834
887
for SSL connections\n\
1087
1140
    ADD_METHOD(bio_shutdown),
1088
1141
    ADD_METHOD(shutdown),
1089
1142
    ADD_METHOD(get_cipher_list),
 
1143
    ADD_METHOD(get_client_ca_list),
1090
1144
    ADD_METHOD(makefile),
1091
1145
    ADD_METHOD(get_app_data),
1092
1146
    ADD_METHOD(set_app_data),