openconnect_create_useragent;
openconnect_report_ssl_errors;
openconnect_get_cert_details;
+ openconnect_get_cert_DER;
openconnect_sha1;
};
struct x509_st *cert, char *buf);
char *openconnect_get_cert_details(struct openconnect_info *vpninfo,
struct x509_st *cert);
+/* Returns the length of the created DER output, in a newly-allocated buffer
+ that will need to be freed by the caller. */
+int openconnect_get_cert_DER(struct openconnect_info *vpninfo,
+ struct x509_st *cert, unsigned char **buf);
int openconnect_set_http_proxy(struct openconnect_info *vpninfo, char *proxy);
int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo);
int openconnect_obtain_cookie(struct openconnect_info *vpninfo);
* Boston, MA 02110-1301 USA
*/
+#include <errno.h>
+
#include <openssl/evp.h>
#include "openconnect-internal.h"
return 0;
}
+
+int openconnect_get_cert_DER(struct openconnect_info *vpninfo,
+ struct x509_st *cert, unsigned char **buf)
+{
+ BIO *bp = BIO_new(BIO_s_mem());
+ BUF_MEM *certinfo;
+ size_t l;
+
+ if (!i2d_X509_bio(bp, cert)) {
+ BIO_free(bp);
+ return -EIO;
+ }
+
+ BIO_get_mem_ptr(bp, &certinfo);
+ l = certinfo->length;
+ *buf = malloc(l);
+ if (!*buf) {
+ BIO_free(bp);
+ return -ENOMEM;
+ }
+ memcpy(*buf, certinfo->data, l);
+ BIO_free(bp);
+ return l;
+}