comparison libpurple/plugins/ssl/ssl-gnutls.c @ 32672:3828a61c44da

A boring and large patch so I can merge heads.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 23 Dec 2011 08:21:58 +0000
parents 43af903bd816
children 298080cecdc5
comparison
equal deleted inserted replaced
32671:0e69949b3e61 32672:3828a61c44da
1140 } 1140 }
1141 1141
1142 return success; 1142 return success;
1143 } 1143 }
1144 1144
1145 static GByteArray *
1146 x509_get_der_data(PurpleCertificate *crt)
1147 {
1148 gnutls_x509_crt crt_dat;
1149 GByteArray *data;
1150 size_t len;
1151 int ret;
1152
1153 crt_dat = X509_GET_GNUTLS_DATA(crt);
1154 g_return_val_if_fail(crt_dat, NULL);
1155
1156 /* Obtain the output size required */
1157 len = 0;
1158 ret = gnutls_x509_crt_export(crt_dat, GNUTLS_X509_FMT_DER, NULL, &len);
1159 g_return_val_if_fail(ret == GNUTLS_E_SHORT_MEMORY_BUFFER, NULL);
1160
1161 /* Now allocate a buffer and *really* export it */
1162 data = g_byte_array_sized_new(len);
1163 data->len = len;
1164 ret = gnutls_x509_crt_export(crt_dat, GNUTLS_X509_FMT_DER, data->data, &len);
1165 if (ret != 0) {
1166 purple_debug_error("gnutls/x509",
1167 "Failed to export cert to buffer with code %d\n",
1168 ret);
1169 g_byte_array_free(data, TRUE);
1170 return NULL;
1171 }
1172
1173 return data;
1174 }
1175
1145 /* X.509 certificate operations provided by this plugin */ 1176 /* X.509 certificate operations provided by this plugin */
1146 static PurpleCertificateScheme x509_gnutls = { 1177 static PurpleCertificateScheme x509_gnutls = {
1147 "x509", /* Scheme name */ 1178 "x509", /* Scheme name */
1148 N_("X.509 Certificates"), /* User-visible scheme name */ 1179 N_("X.509 Certificates"), /* User-visible scheme name */
1149 x509_import_from_file, /* Certificate import function */ 1180 x509_import_from_file, /* Certificate import function */
1156 x509_issuer_dn, /* Issuer Unique ID */ 1187 x509_issuer_dn, /* Issuer Unique ID */
1157 x509_common_name, /* Subject name */ 1188 x509_common_name, /* Subject name */
1158 x509_check_name, /* Check subject name */ 1189 x509_check_name, /* Check subject name */
1159 x509_times, /* Activation/Expiration time */ 1190 x509_times, /* Activation/Expiration time */
1160 x509_importcerts_from_file, /* Multiple certificates import function */ 1191 x509_importcerts_from_file, /* Multiple certificates import function */
1161 1192 x509_get_der_data, /* Binary DER data */
1162 NULL, 1193
1163 NULL, 1194 NULL,
1164 NULL 1195 NULL
1165 1196
1166 }; 1197 };
1167 1198