- if (OK && (director->tls_enable || director->tls_require)) {
- /* Initialize TLS context:
- * Args: CA certfile, CA certdir, Certfile, Keyfile,
- * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer */
- director->tls_ctx = new_tls_context(director->tls_ca_certfile,
- director->tls_ca_certdir, director->tls_certfile,
- director->tls_keyfile, NULL, NULL, director->tls_dhfile,
- director->tls_verify_peer);
-
- if (!director->tls_ctx) {
- Jmsg(NULL, M_FATAL, 0, _("Failed to initialize TLS context for Director \"%s\" in %s.\n"),
- director->hdr.name, configfile);
- OK = false;
- }
- }
- }
-#endif /* HAVE_TLS */
-
- /* Ensure that the media_type for each device is the same */
- foreach_res(changer, R_AUTOCHANGER) {
- DEVRES *device;
- char *media_type = NULL;
- foreach_alist(device, changer->device) {
- if (media_type == NULL) {
- media_type = device->media_type;
- continue;
- }
- if (strcmp(media_type, device->media_type) != 0) {
- Jmsg(NULL, M_ERROR, 0,
- _("Media Type not the same for all devices in changer %s. Cannot continue.\n"),
- changer->hdr.name);
- OK = false;
- continue;
- }
- /*
- * If the device does not have a changer name or changer command
- * defined, used the one from the Autochanger resource
- */
- if (!device->changer_name) {
- device->changer_name = bstrdup(changer->changer_name);
- }
- if (!device->changer_command) {
- device->changer_command = bstrdup(changer->changer_command);
+ if (OK && (tls_needed || director->tls_require)) {
+ /* Initialize TLS context:
+ * Args: CA certfile, CA certdir, Certfile, Keyfile,
+ * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer */
+ director->tls_ctx = new_tls_context(director->tls_ca_certfile,
+ director->tls_ca_certdir, director->tls_certfile,
+ director->tls_keyfile, NULL, NULL, director->tls_dhfile,
+ director->tls_verify_peer);
+
+ if (!director->tls_ctx) {
+ Jmsg(NULL, M_FATAL, 0, _("Failed to initialize TLS context for Director \"%s\" in %s.\n"),
+ director->hdr.name, configfile);
+ OK = false;