summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gmrequest.c9
-rw-r--r--src/gmrequest.h1
-rw-r--r--src/ui/documentwidget.c12
3 files changed, 18 insertions, 4 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c
index d2683135..9591885a 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -17,6 +17,7 @@ void init_GmResponse(iGmResponse *d) {
17 init_Block(&d->body, 0); 17 init_Block(&d->body, 0);
18 d->certFlags = 0; 18 d->certFlags = 0;
19 iZap(d->certValidUntil); 19 iZap(d->certValidUntil);
20 init_String(&d->certSubject);
20} 21}
21 22
22void initCopy_GmResponse(iGmResponse *d, const iGmResponse *other) { 23void initCopy_GmResponse(iGmResponse *d, const iGmResponse *other) {
@@ -25,9 +26,11 @@ void initCopy_GmResponse(iGmResponse *d, const iGmResponse *other) {
25 initCopy_Block(&d->body, &other->body); 26 initCopy_Block(&d->body, &other->body);
26 d->certFlags = other->certFlags; 27 d->certFlags = other->certFlags;
27 d->certValidUntil = other->certValidUntil; 28 d->certValidUntil = other->certValidUntil;
29 initCopy_String(&d->certSubject, &other->certSubject);
28} 30}
29 31
30void deinit_GmResponse(iGmResponse *d) { 32void deinit_GmResponse(iGmResponse *d) {
33 deinit_String(&d->certSubject);
31 deinit_Block(&d->body); 34 deinit_Block(&d->body);
32 deinit_String(&d->meta); 35 deinit_String(&d->meta);
33} 36}
@@ -38,6 +41,7 @@ void clear_GmResponse(iGmResponse *d) {
38 clear_Block(&d->body); 41 clear_Block(&d->body);
39 d->certFlags = 0; 42 d->certFlags = 0;
40 iZap(d->certValidUntil); 43 iZap(d->certValidUntil);
44 clear_String(&d->certSubject);
41} 45}
42 46
43iGmResponse *copy_GmResponse(const iGmResponse *d) { 47iGmResponse *copy_GmResponse(const iGmResponse *d) {
@@ -117,7 +121,7 @@ void setUrl_GmRequest(iGmRequest *d, const iString *url) {
117 121
118static uint32_t timedOutWhileReceivingBody_GmRequest_(uint32_t interval, void *obj) { 122static uint32_t timedOutWhileReceivingBody_GmRequest_(uint32_t interval, void *obj) {
119 iGmRequest *d = obj; 123 iGmRequest *d = obj;
120 iGuardMutex(&d->mutex, cancel_TlsRequest(d->req)); 124 cancel_TlsRequest(d->req);
121 iUnused(interval); 125 iUnused(interval);
122 return 0; 126 return 0;
123} 127}
@@ -146,7 +150,8 @@ static void checkServerCertificate_GmRequest_(iGmRequest *d) {
146 if (checkTrust_GmCerts(certDb, domain, cert)) { 150 if (checkTrust_GmCerts(certDb, domain, cert)) {
147 d->resp.certFlags |= trusted_GmCertFlag; 151 d->resp.certFlags |= trusted_GmCertFlag;
148 } 152 }
149 validUntil_TlsCertificate(serverCertificate_TlsRequest(d->req), &d->resp.certValidUntil); 153 validUntil_TlsCertificate(cert, &d->resp.certValidUntil);
154 set_String(&d->resp.certSubject, collect_String(subject_TlsCertificate(cert)));
150 } 155 }
151} 156}
152 157
diff --git a/src/gmrequest.h b/src/gmrequest.h
index 047edd69..c7d9d738 100644
--- a/src/gmrequest.h
+++ b/src/gmrequest.h
@@ -20,6 +20,7 @@ struct Impl_GmResponse {
20 iBlock body; 20 iBlock body;
21 int certFlags; 21 int certFlags;
22 iDate certValidUntil; 22 iDate certValidUntil;
23 iString certSubject;
23}; 24};
24 25
25iDeclareTypeConstruction(GmResponse) 26iDeclareTypeConstruction(GmResponse)
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 7ae43458..9c8c93c6 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -87,6 +87,7 @@ struct Impl_DocumentWidget {
87 iGmDocument *doc; 87 iGmDocument *doc;
88 int certFlags; 88 int certFlags;
89 iDate certExpiry; 89 iDate certExpiry;
90 iString *certSubject;
90 iBool selecting; 91 iBool selecting;
91 iRangecc selectMark; 92 iRangecc selectMark;
92 iRangecc foundMark; 93 iRangecc foundMark;
@@ -121,6 +122,7 @@ void init_DocumentWidget(iDocumentWidget *d) {
121 d->textSizePercent = 100; 122 d->textSizePercent = 100;
122 d->doc = new_GmDocument(); 123 d->doc = new_GmDocument();
123 d->certFlags = 0; 124 d->certFlags = 0;
125 d->certSubject = new_String();
124 d->selecting = iFalse; 126 d->selecting = iFalse;
125 d->selectMark = iNullRange; 127 d->selectMark = iNullRange;
126 d->foundMark = iNullRange; 128 d->foundMark = iNullRange;
@@ -151,6 +153,7 @@ void deinit_DocumentWidget(iDocumentWidget *d) {
151 iRelease(d->doc); 153 iRelease(d->doc);
152 deinit_PtrArray(&d->visibleLinks); 154 deinit_PtrArray(&d->visibleLinks);
153 delete_String(d->url); 155 delete_String(d->url);
156 delete_String(d->certSubject);
154 delete_String(d->titleUser); 157 delete_String(d->titleUser);
155 SDL_FreeCursor(d->arrowCursor); 158 SDL_FreeCursor(d->arrowCursor);
156 SDL_FreeCursor(d->beamCursor); 159 SDL_FreeCursor(d->beamCursor);
@@ -411,6 +414,7 @@ static void updateTrust_DocumentWidget_(iDocumentWidget *d, const iGmResponse *r
411#define closedLock_CStr "\U0001f512" 414#define closedLock_CStr "\U0001f512"
412 d->certFlags = response->certFlags; 415 d->certFlags = response->certFlags;
413 d->certExpiry = response->certValidUntil; 416 d->certExpiry = response->certValidUntil;
417 set_String(d->certSubject, &response->certSubject);
414 iLabelWidget *lock = findWidget_App("navbar.lock"); 418 iLabelWidget *lock = findWidget_App("navbar.lock");
415 if (~d->certFlags & available_GmCertFlag) { 419 if (~d->certFlags & available_GmCertFlag) {
416 setFlags_Widget(as_Widget(lock), disabled_WidgetFlag, iTrue); 420 setFlags_Widget(as_Widget(lock), disabled_WidgetFlag, iTrue);
@@ -710,12 +714,15 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
710 const char *checked = green_ColorEscape "\u2611"; 714 const char *checked = green_ColorEscape "\u2611";
711 makeMessage_Widget( 715 makeMessage_Widget(
712 cyan_ColorEscape "CERTIFICATE STATUS", 716 cyan_ColorEscape "CERTIFICATE STATUS",
713 format_CStr("%s%s Domain name %s\n" 717 format_CStr("%s%s Domain name %s%s\n"
714 "%s%s %s (%04d-%02d-%02d %02d:%02d:%02d)\n" 718 "%s%s %s (%04d-%02d-%02d %02d:%02d:%02d)\n"
715 "%s%s %s", 719 "%s%s %s",
716 d->certFlags & domainVerified_GmCertFlag ? checked : unchecked, 720 d->certFlags & domainVerified_GmCertFlag ? checked : unchecked,
717 gray75_ColorEscape, 721 gray75_ColorEscape,
718 d->certFlags & domainVerified_GmCertFlag ? "matches" : "mismatch", 722 d->certFlags & domainVerified_GmCertFlag ? "matches" : "mismatch",
723 ~d->certFlags & domainVerified_GmCertFlag
724 ? format_CStr(" (%s)", cstr_String(d->certSubject))
725 : "",
719 d->certFlags & timeVerified_GmCertFlag ? checked : unchecked, 726 d->certFlags & timeVerified_GmCertFlag ? checked : unchecked,
720 gray75_ColorEscape, 727 gray75_ColorEscape,
721 d->certFlags & timeVerified_GmCertFlag ? "Not expired" : "Expired", 728 d->certFlags & timeVerified_GmCertFlag ? "Not expired" : "Expired",
@@ -727,7 +734,8 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
727 d->certExpiry.second, 734 d->certExpiry.second,
728 d->certFlags & trusted_GmCertFlag ? checked : unchecked, 735 d->certFlags & trusted_GmCertFlag ? checked : unchecked,
729 gray75_ColorEscape, 736 gray75_ColorEscape,
730 d->certFlags & trusted_GmCertFlag ? "Trusted on first use" : "Not trusted")); 737 d->certFlags & trusted_GmCertFlag ? "Trusted on first use"
738 : "Not trusted"));
731 return iTrue; 739 return iTrue;
732 } 740 }
733 else if (equal_Command(cmd, "copy")) { 741 else if (equal_Command(cmd, "copy")) {