Fossil SCM
Fix indentation and formatting in http_ssl.c. Limit line length to 80 characters per the coding style spec.
Commit
5eb8f0157a1bbee630f713d1b8894d26435ee9a5
Parent
0554dbd04a751da…
1 file changed
+14
-6
+14
-6
| --- src/http_ssl.c | ||
| +++ src/http_ssl.c | ||
| @@ -97,10 +97,11 @@ | ||
| 97 | 97 | ** Call this routine once before any other use of the SSL interface. |
| 98 | 98 | ** This routine does initial configuration of the SSL module. |
| 99 | 99 | */ |
| 100 | 100 | void ssl_global_init(void){ |
| 101 | 101 | const char *zCaSetting = 0, *zCaFile = 0, *zCaDirectory = 0; |
| 102 | + const char *identityFile; | |
| 102 | 103 | |
| 103 | 104 | if( sslIsInit==0 ){ |
| 104 | 105 | SSL_library_init(); |
| 105 | 106 | SSL_load_error_strings(); |
| 106 | 107 | ERR_load_BIO_strings(); |
| @@ -135,19 +136,26 @@ | ||
| 135 | 136 | fossil_fatal("Failed to use CA root certificates from " |
| 136 | 137 | "ssl-ca-location '%s'", zCaSetting); |
| 137 | 138 | } |
| 138 | 139 | } |
| 139 | 140 | |
| 140 | - /* Load client SSL identity, preferring the filename specified on the command line */ | |
| 141 | - const char *identityFile = ( g.zSSLIdentity!= 0) ? g.zSSLIdentity : db_get("ssl-identity", 0); | |
| 141 | + /* Load client SSL identity, preferring the filename specified on the | |
| 142 | + ** command line */ | |
| 143 | + if( g.zSSLIdentity!=0 ){ | |
| 144 | + identityFile = g.zSSLIdentity; | |
| 145 | + }else{ | |
| 146 | + identityFile = db_get("ssl-identity", 0); | |
| 147 | + } | |
| 142 | 148 | if( identityFile!=0 && identityFile[0]!='\0' ){ |
| 143 | - if( SSL_CTX_use_certificate_file(sslCtx, identityFile, SSL_FILETYPE_PEM)!= 1 | |
| 144 | - || SSL_CTX_use_PrivateKey_file(sslCtx, identityFile, SSL_FILETYPE_PEM)!=1 ){ | |
| 149 | + if( SSL_CTX_use_certificate_file(sslCtx,identityFile,SSL_FILETYPE_PEM)!=1 | |
| 150 | + || SSL_CTX_use_PrivateKey_file(sslCtx,identityFile,SSL_FILETYPE_PEM)!=1 | |
| 151 | + ){ | |
| 145 | 152 | fossil_fatal("Could not load SSL identity from %s", identityFile); |
| 146 | 153 | } |
| 147 | 154 | } |
| 148 | - /* Register a callback to tell the user what to do when the server asks for a cert */ | |
| 155 | + /* Register a callback to tell the user what to do when the server asks | |
| 156 | + ** for a cert */ | |
| 149 | 157 | SSL_CTX_set_client_cert_cb(sslCtx, ssl_client_cert_callback); |
| 150 | 158 | |
| 151 | 159 | sslIsInit = 1; |
| 152 | 160 | } |
| 153 | 161 | } |
| @@ -185,11 +193,11 @@ | ||
| 185 | 193 | */ |
| 186 | 194 | int ssl_open(void){ |
| 187 | 195 | X509 *cert; |
| 188 | 196 | int hasSavedCertificate = 0; |
| 189 | 197 | int trusted = 0; |
| 190 | -char *connStr ; | |
| 198 | + char *connStr ; | |
| 191 | 199 | ssl_global_init(); |
| 192 | 200 | |
| 193 | 201 | /* Get certificate for current server from global config and |
| 194 | 202 | * (if we have it in config) add it to certificate store. |
| 195 | 203 | */ |
| 196 | 204 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -97,10 +97,11 @@ | |
| 97 | ** Call this routine once before any other use of the SSL interface. |
| 98 | ** This routine does initial configuration of the SSL module. |
| 99 | */ |
| 100 | void ssl_global_init(void){ |
| 101 | const char *zCaSetting = 0, *zCaFile = 0, *zCaDirectory = 0; |
| 102 | |
| 103 | if( sslIsInit==0 ){ |
| 104 | SSL_library_init(); |
| 105 | SSL_load_error_strings(); |
| 106 | ERR_load_BIO_strings(); |
| @@ -135,19 +136,26 @@ | |
| 135 | fossil_fatal("Failed to use CA root certificates from " |
| 136 | "ssl-ca-location '%s'", zCaSetting); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /* Load client SSL identity, preferring the filename specified on the command line */ |
| 141 | const char *identityFile = ( g.zSSLIdentity!= 0) ? g.zSSLIdentity : db_get("ssl-identity", 0); |
| 142 | if( identityFile!=0 && identityFile[0]!='\0' ){ |
| 143 | if( SSL_CTX_use_certificate_file(sslCtx, identityFile, SSL_FILETYPE_PEM)!= 1 |
| 144 | || SSL_CTX_use_PrivateKey_file(sslCtx, identityFile, SSL_FILETYPE_PEM)!=1 ){ |
| 145 | fossil_fatal("Could not load SSL identity from %s", identityFile); |
| 146 | } |
| 147 | } |
| 148 | /* Register a callback to tell the user what to do when the server asks for a cert */ |
| 149 | SSL_CTX_set_client_cert_cb(sslCtx, ssl_client_cert_callback); |
| 150 | |
| 151 | sslIsInit = 1; |
| 152 | } |
| 153 | } |
| @@ -185,11 +193,11 @@ | |
| 185 | */ |
| 186 | int ssl_open(void){ |
| 187 | X509 *cert; |
| 188 | int hasSavedCertificate = 0; |
| 189 | int trusted = 0; |
| 190 | char *connStr ; |
| 191 | ssl_global_init(); |
| 192 | |
| 193 | /* Get certificate for current server from global config and |
| 194 | * (if we have it in config) add it to certificate store. |
| 195 | */ |
| 196 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -97,10 +97,11 @@ | |
| 97 | ** Call this routine once before any other use of the SSL interface. |
| 98 | ** This routine does initial configuration of the SSL module. |
| 99 | */ |
| 100 | void ssl_global_init(void){ |
| 101 | const char *zCaSetting = 0, *zCaFile = 0, *zCaDirectory = 0; |
| 102 | const char *identityFile; |
| 103 | |
| 104 | if( sslIsInit==0 ){ |
| 105 | SSL_library_init(); |
| 106 | SSL_load_error_strings(); |
| 107 | ERR_load_BIO_strings(); |
| @@ -135,19 +136,26 @@ | |
| 136 | fossil_fatal("Failed to use CA root certificates from " |
| 137 | "ssl-ca-location '%s'", zCaSetting); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | /* Load client SSL identity, preferring the filename specified on the |
| 142 | ** command line */ |
| 143 | if( g.zSSLIdentity!=0 ){ |
| 144 | identityFile = g.zSSLIdentity; |
| 145 | }else{ |
| 146 | identityFile = db_get("ssl-identity", 0); |
| 147 | } |
| 148 | if( identityFile!=0 && identityFile[0]!='\0' ){ |
| 149 | if( SSL_CTX_use_certificate_file(sslCtx,identityFile,SSL_FILETYPE_PEM)!=1 |
| 150 | || SSL_CTX_use_PrivateKey_file(sslCtx,identityFile,SSL_FILETYPE_PEM)!=1 |
| 151 | ){ |
| 152 | fossil_fatal("Could not load SSL identity from %s", identityFile); |
| 153 | } |
| 154 | } |
| 155 | /* Register a callback to tell the user what to do when the server asks |
| 156 | ** for a cert */ |
| 157 | SSL_CTX_set_client_cert_cb(sslCtx, ssl_client_cert_callback); |
| 158 | |
| 159 | sslIsInit = 1; |
| 160 | } |
| 161 | } |
| @@ -185,11 +193,11 @@ | |
| 193 | */ |
| 194 | int ssl_open(void){ |
| 195 | X509 *cert; |
| 196 | int hasSavedCertificate = 0; |
| 197 | int trusted = 0; |
| 198 | char *connStr ; |
| 199 | ssl_global_init(); |
| 200 | |
| 201 | /* Get certificate for current server from global config and |
| 202 | * (if we have it in config) add it to certificate store. |
| 203 | */ |
| 204 |