diff options
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 33f49ad9..94168d28 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -26,6 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
26 | #include "audio/player.h" | 26 | #include "audio/player.h" |
27 | #include "command.h" | 27 | #include "command.h" |
28 | #include "defs.h" | 28 | #include "defs.h" |
29 | #include "gmcerts.h" | ||
29 | #include "gmdocument.h" | 30 | #include "gmdocument.h" |
30 | #include "gmrequest.h" | 31 | #include "gmrequest.h" |
31 | #include "gmutil.h" | 32 | #include "gmutil.h" |
@@ -137,6 +138,7 @@ struct Impl_DocumentWidget { | |||
137 | iTime sourceTime; | 138 | iTime sourceTime; |
138 | iGmDocument * doc; | 139 | iGmDocument * doc; |
139 | int certFlags; | 140 | int certFlags; |
141 | iBlock * certFingerprint; | ||
140 | iDate certExpiry; | 142 | iDate certExpiry; |
141 | iString * certSubject; | 143 | iString * certSubject; |
142 | int redirectCount; | 144 | int redirectCount; |
@@ -177,6 +179,7 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
177 | init_PersistentDocumentState(&d->mod); | 179 | init_PersistentDocumentState(&d->mod); |
178 | d->flags = 0; | 180 | d->flags = 0; |
179 | iZap(d->certExpiry); | 181 | iZap(d->certExpiry); |
182 | d->certFingerprint = new_Block(0); | ||
180 | d->certFlags = 0; | 183 | d->certFlags = 0; |
181 | d->certSubject = new_String(); | 184 | d->certSubject = new_String(); |
182 | d->state = blank_RequestState; | 185 | d->state = blank_RequestState; |
@@ -242,6 +245,7 @@ void deinit_DocumentWidget(iDocumentWidget *d) { | |||
242 | } | 245 | } |
243 | deinit_PtrArray(&d->visiblePlayers); | 246 | deinit_PtrArray(&d->visiblePlayers); |
244 | deinit_PtrArray(&d->visibleLinks); | 247 | deinit_PtrArray(&d->visibleLinks); |
248 | delete_Block(d->certFingerprint); | ||
245 | delete_String(d->certSubject); | 249 | delete_String(d->certSubject); |
246 | delete_String(d->titleUser); | 250 | delete_String(d->titleUser); |
247 | deinit_PersistentDocumentState(&d->mod); | 251 | deinit_PersistentDocumentState(&d->mod); |
@@ -881,6 +885,7 @@ static void updateTrust_DocumentWidget_(iDocumentWidget *d, const iGmResponse *r | |||
881 | if (response) { | 885 | if (response) { |
882 | d->certFlags = response->certFlags; | 886 | d->certFlags = response->certFlags; |
883 | d->certExpiry = response->certValidUntil; | 887 | d->certExpiry = response->certValidUntil; |
888 | set_Block(d->certFingerprint, &response->certFingerprint); | ||
884 | set_String(d->certSubject, &response->certSubject); | 889 | set_String(d->certSubject, &response->certSubject); |
885 | } | 890 | } |
886 | iLabelWidget *lock = findWidget_App("navbar.lock"); | 891 | iLabelWidget *lock = findWidget_App("navbar.lock"); |
@@ -1271,9 +1276,14 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1271 | return iFalse; | 1276 | return iFalse; |
1272 | } | 1277 | } |
1273 | else if (equal_Command(cmd, "server.showcert") && d == document_App()) { | 1278 | else if (equal_Command(cmd, "server.showcert") && d == document_App()) { |
1274 | const char *unchecked = red_ColorEscape "\u2610"; | 1279 | const char *unchecked = red_ColorEscape "\u2610"; |
1275 | const char *checked = green_ColorEscape "\u2611"; | 1280 | const char *checked = green_ColorEscape "\u2611"; |
1276 | makeMessage_Widget( | 1281 | const char *actionLabels[] = { "Dismiss", uiTextCaution_ColorEscape "Trust" }; |
1282 | const char *actionCmds[] = { "message.ok", "server.trustcert" }; | ||
1283 | const iBool canTrust = | ||
1284 | (d->certFlags == (available_GmCertFlag | haveFingerprint_GmCertFlag | | ||
1285 | timeVerified_GmCertFlag | domainVerified_GmCertFlag)); | ||
1286 | iWidget *dlg = makeQuestion_Widget( | ||
1277 | uiHeading_ColorEscape "CERTIFICATE STATUS", | 1287 | uiHeading_ColorEscape "CERTIFICATE STATUS", |
1278 | format_CStr("%s%s Domain name %s%s\n" | 1288 | format_CStr("%s%s Domain name %s%s\n" |
1279 | "%s%s %s (%04d-%02d-%02d %02d:%02d:%02d)\n" | 1289 | "%s%s %s (%04d-%02d-%02d %02d:%02d:%02d)\n" |
@@ -1295,8 +1305,21 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1295 | d->certExpiry.second, | 1305 | d->certExpiry.second, |
1296 | d->certFlags & trusted_GmCertFlag ? checked : unchecked, | 1306 | d->certFlags & trusted_GmCertFlag ? checked : unchecked, |
1297 | uiText_ColorEscape, | 1307 | uiText_ColorEscape, |
1298 | d->certFlags & trusted_GmCertFlag ? "Trusted on first use" | 1308 | d->certFlags & trusted_GmCertFlag ? "Trusted" : "Not trusted"), |
1299 | : "Not trusted")); | 1309 | actionLabels, |
1310 | actionCmds, | ||
1311 | canTrust ? 2 : 1); | ||
1312 | addAction_Widget(dlg, SDLK_ESCAPE, 0, "message.ok"); | ||
1313 | addAction_Widget(dlg, SDLK_SPACE, 0, "message.ok"); | ||
1314 | return iTrue; | ||
1315 | } | ||
1316 | else if (equal_Command(cmd, "server.trustcert")) { | ||
1317 | const iRangecc host = urlHost_String(d->mod.url); | ||
1318 | if (!isEmpty_Block(d->certFingerprint) && !isEmpty_Range(&host)) { | ||
1319 | setTrusted_GmCerts(certs_App(), host, d->certFingerprint, &d->certExpiry); | ||
1320 | d->certFlags |= trusted_GmCertFlag; | ||
1321 | postCommand_App("server.showcert"); | ||
1322 | } | ||
1300 | return iTrue; | 1323 | return iTrue; |
1301 | } | 1324 | } |
1302 | else if (equal_Command(cmd, "copy") && document_App() == d && !focus_Widget()) { | 1325 | else if (equal_Command(cmd, "copy") && document_App() == d && !focus_Widget()) { |