mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Move tls peer cert function
This commit is contained in:
parent
31b0f0b0c8
commit
8950dbb768
@ -236,7 +236,7 @@ cmd_tls_trust(ProfWin *window, const char *const command, gchar **args)
|
|||||||
cons_show("No TLS connection established");
|
cons_show("No TLS connection established");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
TLSCertificate *cert = session_get_tls_peer_cert();
|
TLSCertificate *cert = connection_get_tls_peer_cert();
|
||||||
if (!cert) {
|
if (!cert) {
|
||||||
cons_show("Error getting TLS certificate.");
|
cons_show("Error getting TLS certificate.");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -334,7 +334,7 @@ cmd_tls_cert(ProfWin *window, const char *const command, gchar **args)
|
|||||||
cons_show("No TLS connection established");
|
cons_show("No TLS connection established");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
TLSCertificate *cert = session_get_tls_peer_cert();
|
TLSCertificate *cert = connection_get_tls_peer_cert();
|
||||||
if (!cert) {
|
if (!cert) {
|
||||||
cons_show("Error getting TLS certificate.");
|
cons_show("Error getting TLS certificate.");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -266,6 +266,30 @@ connection_is_secured(void)
|
|||||||
return xmpp_conn_is_secured(conn.conn);
|
return xmpp_conn_is_secured(conn.conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBMESODE
|
||||||
|
TLSCertificate*
|
||||||
|
connection_get_tls_peer_cert(void)
|
||||||
|
{
|
||||||
|
xmpp_tlscert_t *xmpptlscert = xmpp_conn_tls_peer_cert(conn.conn);
|
||||||
|
int version = xmpp_conn_tlscert_version(xmpptlscert);
|
||||||
|
char *serialnumber = xmpp_conn_tlscert_serialnumber(xmpptlscert);
|
||||||
|
char *subjectname = xmpp_conn_tlscert_subjectname(xmpptlscert);
|
||||||
|
char *issuername = xmpp_conn_tlscert_issuername(xmpptlscert);
|
||||||
|
char *fingerprint = xmpp_conn_tlscert_fingerprint(xmpptlscert);
|
||||||
|
char *notbefore = xmpp_conn_tlscert_notbefore(xmpptlscert);
|
||||||
|
char *notafter = xmpp_conn_tlscert_notafter(xmpptlscert);
|
||||||
|
char *key_alg = xmpp_conn_tlscert_key_algorithm(xmpptlscert);
|
||||||
|
char *signature_alg = xmpp_conn_tlscert_signature_algorithm(xmpptlscert);
|
||||||
|
|
||||||
|
TLSCertificate *cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
|
||||||
|
notafter, key_alg, signature_alg);
|
||||||
|
|
||||||
|
xmpp_conn_free_tlscert(conn.ctx, xmpptlscert);
|
||||||
|
|
||||||
|
return cert;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_connection_handler(xmpp_conn_t *const conn, const xmpp_conn_event_t status, const int error,
|
_connection_handler(xmpp_conn_t *const conn, const xmpp_conn_event_t status, const int error,
|
||||||
xmpp_stream_error_t *const stream_error, void *const userdata)
|
xmpp_stream_error_t *const stream_error, void *const userdata)
|
||||||
|
@ -401,30 +401,6 @@ session_login_failed(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBMESODE
|
|
||||||
TLSCertificate*
|
|
||||||
session_get_tls_peer_cert(void)
|
|
||||||
{
|
|
||||||
xmpp_tlscert_t *xmpptlscert = xmpp_conn_tls_peer_cert(connection_get_conn());
|
|
||||||
int version = xmpp_conn_tlscert_version(xmpptlscert);
|
|
||||||
char *serialnumber = xmpp_conn_tlscert_serialnumber(xmpptlscert);
|
|
||||||
char *subjectname = xmpp_conn_tlscert_subjectname(xmpptlscert);
|
|
||||||
char *issuername = xmpp_conn_tlscert_issuername(xmpptlscert);
|
|
||||||
char *fingerprint = xmpp_conn_tlscert_fingerprint(xmpptlscert);
|
|
||||||
char *notbefore = xmpp_conn_tlscert_notbefore(xmpptlscert);
|
|
||||||
char *notafter = xmpp_conn_tlscert_notafter(xmpptlscert);
|
|
||||||
char *key_alg = xmpp_conn_tlscert_key_algorithm(xmpptlscert);
|
|
||||||
char *signature_alg = xmpp_conn_tlscert_signature_algorithm(xmpptlscert);
|
|
||||||
|
|
||||||
TLSCertificate *cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
|
|
||||||
notafter, key_alg, signature_alg);
|
|
||||||
|
|
||||||
xmpp_conn_free_tlscert(connection_get_ctx(), xmpptlscert);
|
|
||||||
|
|
||||||
return cert;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
session_conn_is_secured(void)
|
session_conn_is_secured(void)
|
||||||
{
|
{
|
||||||
|
@ -121,9 +121,6 @@ char* session_get_account_name(void);
|
|||||||
GList* session_get_available_resources(void);
|
GList* session_get_available_resources(void);
|
||||||
gboolean session_send_stanza(const char *const stanza);
|
gboolean session_send_stanza(const char *const stanza);
|
||||||
|
|
||||||
#ifdef HAVE_LIBMESODE
|
|
||||||
TLSCertificate* session_get_tls_peer_cert(void);
|
|
||||||
#endif
|
|
||||||
gboolean session_conn_is_secured(void);
|
gboolean session_conn_is_secured(void);
|
||||||
gboolean session_send_stanza(const char *const stanza);
|
gboolean session_send_stanza(const char *const stanza);
|
||||||
gboolean session_service_supports(const char *const feature);
|
gboolean session_service_supports(const char *const feature);
|
||||||
@ -133,6 +130,9 @@ char *connection_get_presence_msg(void);
|
|||||||
const char* connection_get_fulljid(void);
|
const char* connection_get_fulljid(void);
|
||||||
char* connection_create_uuid(void);
|
char* connection_create_uuid(void);
|
||||||
void connection_free_uuid(char *uuid);
|
void connection_free_uuid(char *uuid);
|
||||||
|
#ifdef HAVE_LIBMESODE
|
||||||
|
TLSCertificate* connection_get_tls_peer_cert(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
char* message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url);
|
char* message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url);
|
||||||
char* message_send_chat_otr(const char *const barejid, const char *const msg);
|
char* message_send_chat_otr(const char *const barejid, const char *const msg);
|
||||||
|
@ -43,7 +43,7 @@ gboolean session_conn_is_secured(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TLSCertificate*
|
TLSCertificate*
|
||||||
session_get_tls_peer_cert(void)
|
connection_get_tls_peer_cert(void)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user