make sure ssl_dir is created before writing to cert_file, update #1671