Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | A general simplification of the server-side TLS logic: Do not store server-certs in settings. Remove the ssl-config subcommands that try to do that. Change command-line options for server-TLS mode on "fossil server" and "fossil http": --cert for the cert file, --pkey for the private key, and omit --tls and --ssl. This check-in supercedes [/timeline?r=tls-server-fix|the tls-server-fix branch]. See [forum:/forumpost/de470658fdf45100|forum post de470658fdf45100]. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
d7008b34579d2f411784cedca493b05c |
| User & Date: | drh 2022-01-17 16:56:51.467 |
References
|
2022-01-17
| ||
| 13:47 | This branch superceded by [d7008b34579d2f41|check-in d7008b34579d2f41] and therefore closed. Was: move the checking for --https to before verify_options is called Closed-Leaf check-in: 60d1581ff0 user: rdb tags: tls-server-fix | |
Context
|
2022-01-17
| ||
| 18:10 | Fix the "fossil sync" command so that it works with options -u and --all at the same time. check-in: 95014ae996 user: drh tags: trunk | |
| 16:56 | A general simplification of the server-side TLS logic: Do not store server-certs in settings. Remove the ssl-config subcommands that try to do that. Change command-line options for server-TLS mode on "fossil server" and "fossil http": --cert for the cert file, --pkey for the private key, and omit --tls and --ssl. This check-in supercedes [/timeline?r=tls-server-fix|the tls-server-fix branch]. See [forum:/forumpost/de470658fdf45100|forum post de470658fdf45100]. check-in: d7008b3457 user: drh tags: trunk | |
|
2022-01-16
| ||
| 18:42 | The output of "fossil configuration --help" had two different ways -R was described, one wrong. The newer one was of a more consistent format with the rest of the help ([decd537016 | thus why it was added]) so removed the older one and reworked the newer one to be more accurate. check-in: 6cb0fc2591 user: wyoung tags: trunk | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
4290 4291 4292 4293 4294 4295 4296 | ** If set, this will override the OS default list of ** OpenSSL CAs. If unset, the default list will be used. ** Some platforms may add additional certificates. ** Checking your platform behaviour is required if the ** exact contents of the CA root is critical for your ** application. */ | < < < < < < < < < < < < < < < < < < < | 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 | ** If set, this will override the OS default list of ** OpenSSL CAs. If unset, the default list will be used. ** Some platforms may add additional certificates. ** Checking your platform behaviour is required if the ** exact contents of the CA root is critical for your ** application. */ /* ** SETTING: ssl-identity width=40 sensitive ** The full pathname to a file containing a certificate ** and private key in PEM format. Create by concatenating ** the certificate and private key files. ** ** This identity will be presented to SSL servers to ** authenticate this client, in addition to the normal ** password authentication. */ #ifdef FOSSIL_ENABLE_TCL /* ** SETTING: tcl boolean default=off sensitive ** If enabled Tcl integration commands will be added to the TH1 ** interpreter, allowing arbitrary Tcl expressions and ** scripts to be evaluated from TH1. Additionally, the Tcl ** interpreter will be able to evaluate arbitrary TH1 |
| ︙ | ︙ |
Changes to src/http_ssl.c.
| ︙ | ︙ | |||
695 696 697 698 699 700 701 | ** ** If zKeyFile and zCertFile are not NULL, then they are the names ** of disk files that hold the certificate and private-key for the ** server. If zCertFile is not NULL but zKeyFile is NULL, then ** zCertFile is assumed to be a concatenation of the certificate and ** the private-key in the PEM format. ** | < < < | > > | < | > > > > > > > > > > | < | < < < < | < > | < < < > | 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
**
** If zKeyFile and zCertFile are not NULL, then they are the names
** of disk files that hold the certificate and private-key for the
** server. If zCertFile is not NULL but zKeyFile is NULL, then
** zCertFile is assumed to be a concatenation of the certificate and
** the private-key in the PEM format.
**
** If zCertFile is "unsafe-builtin", then a built-in self-signed cert
** is used. This built-in cert is insecure and should only be used for
** testing and debugging.
*/
void ssl_init_server(const char *zCertFile, const char *zKeyFile){
if( sslIsInit==0 && zCertFile ){
SSL_library_init();
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
sslCtx = SSL_CTX_new(SSLv23_server_method());
if( sslCtx==0 ){
ERR_print_errors_fp(stderr);
fossil_fatal("Error initializing the SSL server");
}
if( fossil_strcmp(zCertFile,"unsafe-builtin")==0 ){
if( sslctx_use_cert_from_mem(sslCtx, sslSelfCert, -1)
|| sslctx_use_pkey_from_mem(sslCtx, sslSelfPKey, -1)
){
fossil_fatal("Error loading self-signed CERT and KEY");
}
}else{
if( SSL_CTX_use_certificate_chain_file(sslCtx,zCertFile)!=1 ){
ERR_print_errors_fp(stderr);
fossil_fatal("Error loading CERT file \"%s\"", zCertFile);
}
if( zKeyFile==0 ) zKeyFile = zCertFile;
if( SSL_CTX_use_PrivateKey_file(sslCtx, zKeyFile, SSL_FILETYPE_PEM)<=0 ){
ERR_print_errors_fp(stderr);
if( strcmp(zKeyFile,zCertFile)==0 ){
fossil_fatal("The private key is not found in \"%s\". "
"Either append the private key to the certification in that "
"file or use a separate --pkey option to specify the private key.",
zKeyFile);
}else{
fossil_fatal("Error loading the private key from file \"%s\"",
zKeyFile);
}
}
}
if( !SSL_CTX_check_private_key(sslCtx) ){
fossil_fatal("PRIVATE KEY \"%s\" does not match CERT \"%s\"",
zKeyFile, zCertFile);
}
SSL_CTX_set_mode(sslCtx, SSL_MODE_AUTO_RETRY);
sslIsInit = 2;
|
| ︙ | ︙ | |||
864 865 866 867 868 869 870 | ** ** This command is used to view or modify the TLS (Transport Layer ** Security) configuration for Fossil. TLS (formerly SSL) is the ** encryption technology used for secure HTTPS transport. ** ** Sub-commands: ** | < < < < < < < < < < < | 865 866 867 868 869 870 871 872 873 874 875 876 877 878 | ** ** This command is used to view or modify the TLS (Transport Layer ** Security) configuration for Fossil. TLS (formerly SSL) is the ** encryption technology used for secure HTTPS transport. ** ** Sub-commands: ** ** remove-exception DOMAINS Remove TLS cert exceptions for the domains ** listed. Or remove them all if the --all ** option is specified. ** ** scrub ?--force? Remove all SSL configuration data from the ** repository. Use --force to omit the ** confirmation. |
| ︙ | ︙ | |||
899 900 901 902 903 904 905 |
if( g.argc==2 || (g.argc>=3 && g.argv[2][0]=='-') ){
zCmd = "show";
nCmd = 4;
}else{
zCmd = g.argv[2];
nCmd = strlen(zCmd);
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 889 890 891 892 893 894 895 896 897 898 899 900 901 902 |
if( g.argc==2 || (g.argc>=3 && g.argv[2][0]=='-') ){
zCmd = "show";
nCmd = 4;
}else{
zCmd = g.argv[2];
nCmd = strlen(zCmd);
}
if( strncmp("scrub",zCmd,nCmd)==0 && nCmd>4 ){
int bForce = find_option("force","f",0)!=0;
verify_all_options();
if( !bForce ){
Blob ans;
char cReply;
prompt_user(
|
| ︙ | ︙ | |||
1082 1083 1084 1085 1086 1087 1088 |
" priority over built-in paths and environment variables\n\n"
);
}
fossil_print("ssl-identity: %s\n", db_get("ssl-identity",""));
if( verbose ){
fossil_print("\n"
| | | | | < < < < < < < < < < < < < < < < < < < < < < < | 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 |
" priority over built-in paths and environment variables\n\n"
);
}
fossil_print("ssl-identity: %s\n", db_get("ssl-identity",""));
if( verbose ){
fossil_print("\n"
" This setting is the name of a file that contains the PEM-format\n"
" certificate and private-key used by Fossil clients to authenticate\n"
" with servers. Few servers actually require this, so this setting\n"
" is usually blank.\n\n"
);
}
db_prepare(&q,
"SELECT name, '' FROM global_config"
" WHERE name GLOB 'cert:*'"
"UNION ALL "
|
| ︙ | ︙ | |||
1177 1178 1179 1180 1181 1182 1183 |
db_exec_sql(blob_str(&sql));
db_protect_pop();
db_commit_transaction();
blob_reset(&sql);
}else
/*default*/{
fossil_fatal("unknown sub-command \"%s\".\nshould be one of:"
| | | 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
db_exec_sql(blob_str(&sql));
db_protect_pop();
db_commit_transaction();
blob_reset(&sql);
}else
/*default*/{
fossil_fatal("unknown sub-command \"%s\".\nshould be one of:"
" remove-exception scrub show",
zCmd);
}
}
/*
** WEBPAGE: .well-known
**
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
2595 2596 2597 2598 2599 2600 2601 |
/*
** Check for options to "fossil server" or "fossil ui" that imply that
** SSL should be used, and initialize the SSL decoder.
*/
static void decode_ssl_options(void){
#if FOSSIL_ENABLE_SSL
const char *zCertFile = 0;
| > | > | < | < | | 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 |
/*
** Check for options to "fossil server" or "fossil ui" that imply that
** SSL should be used, and initialize the SSL decoder.
*/
static void decode_ssl_options(void){
#if FOSSIL_ENABLE_SSL
const char *zCertFile = 0;
const char *zKeyFile = 0;
zCertFile = find_option("cert",0,1);
zKeyFile = find_option("pkey",0,1);
if( zCertFile ){
g.httpUseSSL = 1;
ssl_init_server(zCertFile, zKeyFile);
}else if( zKeyFile ){
fossil_fatal("--pkey without a corresponding --cert");
}
#endif
}
/*
** COMMAND: http*
**
|
| ︙ | ︙ | |||
2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 | ** If the --localauth option is given, then automatic login is performed ** for requests coming from localhost, if the "localauth" setting is not ** enabled. ** ** Options: ** --acme Deliver files from the ".well-known" subdirectory ** --baseurl URL base URL (useful with reverse proxies) ** --chroot DIR Use directory for chroot instead of repository path. ** --ckout-alias N Treat URIs of the form /doc/N/... as if they were ** /doc/ckout/... ** --extroot DIR document root for the /ext extension mechanism ** --files GLOB comma-separate glob patterns for static file to serve ** --host NAME specify hostname of the server ** --https signal a request coming in via https | > > | 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 | ** If the --localauth option is given, then automatic login is performed ** for requests coming from localhost, if the "localauth" setting is not ** enabled. ** ** Options: ** --acme Deliver files from the ".well-known" subdirectory ** --baseurl URL base URL (useful with reverse proxies) ** --cert FILE Use TLS (HTTPS) encryption with the certificate (the ** fullchain.pem) taken from FILE. ** --chroot DIR Use directory for chroot instead of repository path. ** --ckout-alias N Treat URIs of the form /doc/N/... as if they were ** /doc/ckout/... ** --extroot DIR document root for the /ext extension mechanism ** --files GLOB comma-separate glob patterns for static file to serve ** --host NAME specify hostname of the server ** --https signal a request coming in via https |
| ︙ | ︙ | |||
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 | ** --nocompress do not compress HTTP replies ** --nodelay omit backoffice processing if it would delay ** process exit ** --nojail drop root privilege but do not enter the chroot jail ** --nossl signal that no SSL connections are available ** --notfound URL use URL as "HTTP 404, object not found" page. ** --out FILE write results to FILE instead of to standard output ** --repolist If REPOSITORY is directory, URL "/" lists all repos ** --scgi Interpret input as SCGI rather than HTTP ** --skin LABEL Use override skin LABEL | > < < < | 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 |
** --nocompress do not compress HTTP replies
** --nodelay omit backoffice processing if it would delay
** process exit
** --nojail drop root privilege but do not enter the chroot jail
** --nossl signal that no SSL connections are available
** --notfound URL use URL as "HTTP 404, object not found" page.
** --out FILE write results to FILE instead of to standard output
** --pkey FILE Read the private key used for TLS from FILE.
** --repolist If REPOSITORY is directory, URL "/" lists all repos
** --scgi Interpret input as SCGI rather than HTTP
** --skin LABEL Use override skin LABEL
** --th-trace trace TH1 execution (for debugging purposes)
** --usepidkey Use saved encryption key from parent process. This is
** only necessary when using SEE on Windows.
**
** See also: [[cgi]], [[server]], [[winsrv]]
*/
void cmd_http(void){
const char *zIpAddr = 0;
|
| ︙ | ︙ | |||
2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 | ** --localauth option is present and the "localauth" setting is off and the ** connection is from localhost. The "ui" command also enables --repolist ** by default. ** ** Options: ** --acme Deliver files from the ".well-known" subdirectory. ** --baseurl URL Use URL as the base (useful for reverse proxies) ** --chroot DIR Use directory for chroot instead of repository path. ** --ckout-alias NAME Treat URIs of the form /doc/NAME/... as if they were ** /doc/ckout/... ** --create Create a new REPOSITORY if it does not already exist ** --extroot DIR Document root for the /ext extension mechanism ** --files GLOBLIST Comma-separated list of glob patterns for static files ** --fossilcmd PATH Full pathname of the "fossil" executable on the remote | > > | 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 | ** --localauth option is present and the "localauth" setting is off and the ** connection is from localhost. The "ui" command also enables --repolist ** by default. ** ** Options: ** --acme Deliver files from the ".well-known" subdirectory. ** --baseurl URL Use URL as the base (useful for reverse proxies) ** --cert FILE Use TLS (HTTPS) encryption with the certificate (the ** fullchain.pem) taken from FILE. ** --chroot DIR Use directory for chroot instead of repository path. ** --ckout-alias NAME Treat URIs of the form /doc/NAME/... as if they were ** /doc/ckout/... ** --create Create a new REPOSITORY if it does not already exist ** --extroot DIR Document root for the /ext extension mechanism ** --files GLOBLIST Comma-separated list of glob patterns for static files ** --fossilcmd PATH Full pathname of the "fossil" executable on the remote |
| ︙ | ︙ | |||
3006 3007 3008 3009 3010 3011 3012 | ** of the given file. ** --max-latency N Do not let any single HTTP request run for more than N ** seconds (only works on unix) ** --nobrowser Do not automatically launch a web-browser for the ** "fossil ui" command. ** --nocompress Do not compress HTTP replies ** --nojail Drop root privileges but do not enter the chroot jail | | > | | > < < < | 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 |
** of the given file.
** --max-latency N Do not let any single HTTP request run for more than N
** seconds (only works on unix)
** --nobrowser Do not automatically launch a web-browser for the
** "fossil ui" command.
** --nocompress Do not compress HTTP replies
** --nojail Drop root privileges but do not enter the chroot jail
** --nossl do not force redirects to SSL even if the repository
** setting "redirect-to-https" requests it. This is set
** by default for the "ui" command.
** --notfound URL Redirect to URL if a page is not found.
** --page PAGE Start "ui" on PAGE. ex: --page "timeline?y=ci"
** --pkey FILE Read the private key used for TLS from FILE.
** -P|--port TCPPORT listen to request on port TCPPORT
** --repolist If REPOSITORY is dir, URL "/" lists repos.
** --scgi Accept SCGI rather than HTTP
** --skin LABEL Use override skin LABEL
** --th-trace trace TH1 execution (for debugging purposes)
** --usepidkey Use saved encryption key from parent process. This is
** only necessary when using SEE on Windows.
**
** See also: [[cgi]], [[http]], [[winsrv]]
*/
void cmd_webserver(void){
int iPort, mxPort; /* Range of TCP ports allowed */
|
| ︙ | ︙ |