+ unbash_spaces(name);
+ cons = (CONRES *)GetResWithName(R_CONSOLE, name);
+ if (cons) {
+#ifdef HAVE_TLS
+ /* TLS Requirement */
+ if (cons->tls_enable) {
+ if (cons->tls_require) {
+ tls_local_need = BNET_TLS_REQUIRED;
+ } else {
+ tls_local_need = BNET_TLS_OK;
+ }
+ }
+
+ if (cons->tls_verify_peer) {
+ verify_list = cons->tls_allowed_cns;
+ }
+#endif /* HAVE_TLS */
+
+ auth_success = cram_md5_auth(ua, cons->password, tls_local_need) &&
+ cram_md5_get_auth(ua, cons->password, &tls_remote_need);
+
+ if (auth_success) {
+ uac->cons = cons; /* save console resource pointer */
+ }
+ } else {
+ auth_success = false;
+ goto auth_done;
+ }
+ }
+
+ /* Verify that the remote peer is willing to meet our TLS requirements */
+ if (tls_remote_need < tls_local_need && tls_local_need != BNET_TLS_OK && tls_remote_need != BNET_TLS_OK) {
+ Emsg0(M_FATAL, 0, _("Authorization problem:"
+ " Remote client did not advertise required TLS support.\n"));
+ auth_success = false;
+ goto auth_done;
+ }
+
+ /* Verify that we are willing to meet the peer's requirements */
+ if (tls_remote_need > tls_local_need && tls_local_need != BNET_TLS_OK && tls_remote_need != BNET_TLS_OK) {
+ Emsg0(M_FATAL, 0, _("Authorization problem:"
+ " Remote client requires TLS.\n"));
+ auth_success = false;
+ goto auth_done;
+ }
+
+#ifdef HAVE_TLS
+ if (tls_local_need >= BNET_TLS_OK && tls_remote_need >= BNET_TLS_OK) {