Index: src/http_ssl.c ================================================================== --- src/http_ssl.c +++ src/http_ssl.c @@ -705,10 +705,12 @@ ** a built-in self-signed cert is used. */ void ssl_init_server(const char *zCertFile, const char *zKeyFile){ if( sslIsInit==0 ){ const char *zTlsCert; + db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0); + db_open_config(1,0); SSL_library_init(); SSL_load_error_strings(); OpenSSL_add_all_algorithms(); sslCtx = SSL_CTX_new(SSLv23_server_method()); if( sslCtx==0 ){ @@ -919,11 +921,11 @@ } db_unprotect(PROTECT_ALL); db_multi_exec( "PRAGMA secure_delete=ON;" "DELETE FROM config " - " WHERE name IN ('ssl-cert','ssl-cert-file','ssl-cert-key');" + " WHERE name IN ('ssl-cert','ssl-cert-file','ssl-key-file');" ); db_protect_pop(); }else if( strncmp("load-cert",zCmd,nCmd)==0 && nCmd>=4 ){ int bFN = find_option("filename",0,0)!=0; @@ -935,11 +937,11 @@ db_begin_transaction(); db_unprotect(PROTECT_ALL); db_multi_exec( "PRAGMA secure_delete=ON;" "DELETE FROM config " - " WHERE name IN ('ssl-cert','ssl-cert-file','ssl-cert-key');" + " WHERE name IN ('ssl-cert','ssl-cert-file','ssl-key-file');" ); nHit = 0; for(i=3; i0 ){ /* If REPOSITORY arg is the root of a checkout, ** chdir to that checkout so that the current version ** gets highlighted in the timeline by default. */ const char * zDir = g.argv[2]; @@ -3166,10 +3190,26 @@ allowRepoList = 1; } if( !zRemote ){ find_server_repository(findServerArg, fCreate); } + /* + ** We need call enable TLS / SSL here as we need query the + ** repo database to access the certificate if its been loaded + ** + ** The database has only just been found and made available + */ +#if FOSSIL_ENABLE_SSL + init_ssl_decoder(zCertFile, zTls); +#endif + if( zHttps !=0 || g.httpUseSSL ){ + cgi_replace_parameter("HTTPS","on"); + } + if( g.httpUseSSL && (flags & HTTP_SERVER_SCGI)!=0 ){ + fossil_fatal("SCGI does not (yet) support TLS-encrypted connections"); + } + if( zInitPage==0 ){ if( isUiCmd && g.localOpen ){ zInitPage = "timeline?c=current"; }else{ zInitPage = "";