- stuff[0] = sprintf((char *)(&stuff[1]),
- "The server's key fingerprint is: %s\n"
- "Continue connecting?", fingerprint);
- ParamText(stuff, NULL, NULL, NULL);
- if (CautionAlert(wQuestion, NULL) == 2) {
- /*
- * User chose "Cancel". Unfortunately, if I tear the
- * connection down here, Bad Things happen when I return. I
- * think this function should actually return something
- * telling the SSH code to abandon the connection.
- */
+ /* Verify the key against the cache */
+
+ ret = verify_host_key(host, port, keytype, keystr);
+
+ if (ret == 0) { /* success - key matched OK */
+ return 1;
+ } else if (ret == 2) { /* key was different */
+ ParamText(pappname, pkeytype, pfingerprint, NULL);
+ alertret=CautionAlert(wWrong, NULL);
+ if (alertret == 8) {
+ /* Cancel */
+ return 0;
+ } else if (alertret == 9) {
+ /* Connect Just Once */
+ return 1;
+ } else {
+ /* Update Key */
+ store_host_key(host, port, keytype, keystr);
+ return 1;
+ }
+ } else /* ret == 1 */ { /* key was absent */
+ ParamText(pkeytype, pfingerprint, pappname, NULL);
+ alertret=CautionAlert(wAbsent, NULL);
+ if (alertret == 7) {
+ /* Cancel */
+ return 0;
+ } else if (alertret == 8) {
+ /* Connect Just Once */
+ return 1;
+ } else {
+ /* Update Key */
+ store_host_key(host, port, keytype, keystr);
+ return 1;
+ }