Fossil SCM
Reformat some code in http_ssl.c
Commit
d92945e5dad0360a1b234a4e11cfb761524f8da6
Parent
16f6fd904a0c88f…
1 file changed
+5
-7
+5
-7
| --- src/http_ssl.c | ||
| +++ src/http_ssl.c | ||
| @@ -135,11 +135,11 @@ | ||
| 135 | 135 | |
| 136 | 136 | /* Get certificate for current server from global config and |
| 137 | 137 | * (if we have it in config) add it to certificate store. |
| 138 | 138 | */ |
| 139 | 139 | cert = ssl_get_certificate(); |
| 140 | - if ( cert != NULL ){ | |
| 140 | + if ( cert!=NULL ){ | |
| 141 | 141 | X509_STORE_add_cert(SSL_CTX_get_cert_store(sslCtx), cert); |
| 142 | 142 | X509_free(cert); |
| 143 | 143 | hasSavedCertificate = 1; |
| 144 | 144 | } |
| 145 | 145 | |
| @@ -170,11 +170,11 @@ | ||
| 170 | 170 | return 1; |
| 171 | 171 | } |
| 172 | 172 | /* Check if certificate is valid */ |
| 173 | 173 | cert = SSL_get_peer_certificate(ssl); |
| 174 | 174 | |
| 175 | - if ( cert == NULL ){ | |
| 175 | + if ( cert==NULL ){ | |
| 176 | 176 | ssl_set_errmsg("No SSL certificate was presented by the peer"); |
| 177 | 177 | ssl_close(); |
| 178 | 178 | return 1; |
| 179 | 179 | } |
| 180 | 180 | |
| @@ -199,11 +199,11 @@ | ||
| 199 | 199 | BIO_free(mem); |
| 200 | 200 | |
| 201 | 201 | Blob ans; |
| 202 | 202 | blob_zero(&ans); |
| 203 | 203 | prompt_user(prompt, &ans); |
| 204 | - free( prompt ); | |
| 204 | + free(prompt); | |
| 205 | 205 | if( blob_str(&ans)[0]!='y' && blob_str(&ans)[0]!='a' ) { |
| 206 | 206 | X509_free(cert); |
| 207 | 207 | ssl_set_errmsg("SSL certificate declined"); |
| 208 | 208 | ssl_close(); |
| 209 | 209 | return 1; |
| @@ -217,12 +217,11 @@ | ||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /* |
| 220 | 220 | ** Save certificate to global config. |
| 221 | 221 | */ |
| 222 | -void ssl_save_certificate(X509 *cert) | |
| 223 | -{ | |
| 222 | +void ssl_save_certificate(X509 *cert){ | |
| 224 | 223 | BIO *mem; |
| 225 | 224 | char *zCert, *zHost; |
| 226 | 225 | |
| 227 | 226 | mem = BIO_new(BIO_s_mem()); |
| 228 | 227 | PEM_write_bio_X509(mem, cert); |
| @@ -236,12 +235,11 @@ | ||
| 236 | 235 | |
| 237 | 236 | /* |
| 238 | 237 | ** Get certificate for g.urlName from global config. |
| 239 | 238 | ** Return NULL if no certificate found. |
| 240 | 239 | */ |
| 241 | -X509 *ssl_get_certificate() | |
| 242 | -{ | |
| 240 | +X509 *ssl_get_certificate(void){ | |
| 243 | 241 | char *zHost, *zCert; |
| 244 | 242 | BIO *mem; |
| 245 | 243 | X509 *cert; |
| 246 | 244 | |
| 247 | 245 | zHost = mprintf("cert:%s", g.urlName); |
| 248 | 246 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -135,11 +135,11 @@ | |
| 135 | |
| 136 | /* Get certificate for current server from global config and |
| 137 | * (if we have it in config) add it to certificate store. |
| 138 | */ |
| 139 | cert = ssl_get_certificate(); |
| 140 | if ( cert != NULL ){ |
| 141 | X509_STORE_add_cert(SSL_CTX_get_cert_store(sslCtx), cert); |
| 142 | X509_free(cert); |
| 143 | hasSavedCertificate = 1; |
| 144 | } |
| 145 | |
| @@ -170,11 +170,11 @@ | |
| 170 | return 1; |
| 171 | } |
| 172 | /* Check if certificate is valid */ |
| 173 | cert = SSL_get_peer_certificate(ssl); |
| 174 | |
| 175 | if ( cert == NULL ){ |
| 176 | ssl_set_errmsg("No SSL certificate was presented by the peer"); |
| 177 | ssl_close(); |
| 178 | return 1; |
| 179 | } |
| 180 | |
| @@ -199,11 +199,11 @@ | |
| 199 | BIO_free(mem); |
| 200 | |
| 201 | Blob ans; |
| 202 | blob_zero(&ans); |
| 203 | prompt_user(prompt, &ans); |
| 204 | free( prompt ); |
| 205 | if( blob_str(&ans)[0]!='y' && blob_str(&ans)[0]!='a' ) { |
| 206 | X509_free(cert); |
| 207 | ssl_set_errmsg("SSL certificate declined"); |
| 208 | ssl_close(); |
| 209 | return 1; |
| @@ -217,12 +217,11 @@ | |
| 217 | } |
| 218 | |
| 219 | /* |
| 220 | ** Save certificate to global config. |
| 221 | */ |
| 222 | void ssl_save_certificate(X509 *cert) |
| 223 | { |
| 224 | BIO *mem; |
| 225 | char *zCert, *zHost; |
| 226 | |
| 227 | mem = BIO_new(BIO_s_mem()); |
| 228 | PEM_write_bio_X509(mem, cert); |
| @@ -236,12 +235,11 @@ | |
| 236 | |
| 237 | /* |
| 238 | ** Get certificate for g.urlName from global config. |
| 239 | ** Return NULL if no certificate found. |
| 240 | */ |
| 241 | X509 *ssl_get_certificate() |
| 242 | { |
| 243 | char *zHost, *zCert; |
| 244 | BIO *mem; |
| 245 | X509 *cert; |
| 246 | |
| 247 | zHost = mprintf("cert:%s", g.urlName); |
| 248 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -135,11 +135,11 @@ | |
| 135 | |
| 136 | /* Get certificate for current server from global config and |
| 137 | * (if we have it in config) add it to certificate store. |
| 138 | */ |
| 139 | cert = ssl_get_certificate(); |
| 140 | if ( cert!=NULL ){ |
| 141 | X509_STORE_add_cert(SSL_CTX_get_cert_store(sslCtx), cert); |
| 142 | X509_free(cert); |
| 143 | hasSavedCertificate = 1; |
| 144 | } |
| 145 | |
| @@ -170,11 +170,11 @@ | |
| 170 | return 1; |
| 171 | } |
| 172 | /* Check if certificate is valid */ |
| 173 | cert = SSL_get_peer_certificate(ssl); |
| 174 | |
| 175 | if ( cert==NULL ){ |
| 176 | ssl_set_errmsg("No SSL certificate was presented by the peer"); |
| 177 | ssl_close(); |
| 178 | return 1; |
| 179 | } |
| 180 | |
| @@ -199,11 +199,11 @@ | |
| 199 | BIO_free(mem); |
| 200 | |
| 201 | Blob ans; |
| 202 | blob_zero(&ans); |
| 203 | prompt_user(prompt, &ans); |
| 204 | free(prompt); |
| 205 | if( blob_str(&ans)[0]!='y' && blob_str(&ans)[0]!='a' ) { |
| 206 | X509_free(cert); |
| 207 | ssl_set_errmsg("SSL certificate declined"); |
| 208 | ssl_close(); |
| 209 | return 1; |
| @@ -217,12 +217,11 @@ | |
| 217 | } |
| 218 | |
| 219 | /* |
| 220 | ** Save certificate to global config. |
| 221 | */ |
| 222 | void ssl_save_certificate(X509 *cert){ |
| 223 | BIO *mem; |
| 224 | char *zCert, *zHost; |
| 225 | |
| 226 | mem = BIO_new(BIO_s_mem()); |
| 227 | PEM_write_bio_X509(mem, cert); |
| @@ -236,12 +235,11 @@ | |
| 235 | |
| 236 | /* |
| 237 | ** Get certificate for g.urlName from global config. |
| 238 | ** Return NULL if no certificate found. |
| 239 | */ |
| 240 | X509 *ssl_get_certificate(void){ |
| 241 | char *zHost, *zCert; |
| 242 | BIO *mem; |
| 243 | X509 *cert; |
| 244 | |
| 245 | zHost = mprintf("cert:%s", g.urlName); |
| 246 |