forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita9bd176
committed
Attached are a revised set of SSL patches. Many of these patches
are motivated by security concerns, it's not just bug fixes. The keydifferences (from stock 7.2.1) are:*) almost all code that directly uses the OpenSSL library is in two new files, src/interfaces/libpq/fe-ssl.c src/backend/postmaster/be-ssl.c in the long run, it would be nice to merge these two files.*) the legacy code to read and write network data have been encapsulated into read_SSL() and write_SSL(). These functions should probably be renamed - they handle both SSL and non-SSL cases. the remaining code should eliminate the problems identified earlier, albeit not very cleanly.*) both front- and back-ends will send a SSL shutdown via the new close_SSL() function. This is necessary for sessions to work properly. (Sessions are not yet fully supported, but by cleanly closing the SSL connection instead of just sending a TCP FIN packet other SSL tools will be much happier.)*) The client certificate and key are now expected in a subdirectory of the user's home directory. Specifically,- the directory .postgresql must be owned by the user, and allow no access by 'group' or 'other.'- the file .postgresql/postgresql.crt must be a regular file owned by the user.- the file .postgresql/postgresql.key must be a regular file owned by the user, and allow no access by 'group' or 'other'. At the current time encrypted private keys are not supported. There should also be a way to support multiple client certs/keys.*) the front-end performs minimal validation of the back-end cert. Self-signed certs are permitted, but the common name *must* match the hostname used by the front-end. (The cert itself should always use a fully qualified domain name (FDQN) in its common name field.) This means that psql -h eris db will fail, but psql -h eris.example.com db will succeed. At the current time this must be an exact match; future patches may support any FQDN that resolves to the address returned by getpeername(2). Another common "problem" is expiring certs. For now, it may be a good idea to use a very-long-lived self-signed cert. As a compile-time option, the front-end can specify a file containing valid root certificates, but it is not yet required.*) the back-end performs minimal validation of the client cert. It allows self-signed certs. It checks for expiration. It supports a compile-time option specifying a file containing valid root certificates.*) both front- and back-ends default to TLSv1, not SSLv3/SSLv2.*) both front- and back-ends support DSA keys. DSA keys are moderately more expensive on startup, but many people consider them preferable than RSA keys. (E.g., SSH2 prefers DSA keys.)*) if /dev/urandom exists, both client and server will read 16k of randomization data from it.*) the server can read empheral DH parameters from the files $DataDir/dh512.pem $DataDir/dh1024.pem $DataDir/dh2048.pem $DataDir/dh4096.pem if none are provided, the server will default to hardcoded parameter files provided by the OpenSSL project.Remaining tasks:*) the select() clauses need to be revisited - the SSL abstraction layer may need to absorb more of the current code to avoid rare deadlock conditions. This also touches on a true solution to the pg_eof() problem.*) the SIGPIPE signal handler may need to be revisited.*) support encrypted private keys.*) sessions are not yet fully supported. (SSL sessions can span multiple "connections," and allow the client and server to avoid costly renegotiations.)*) makecert - a script that creates back-end certs.*) pgkeygen - a tool that creates front-end certs.*) the whole protocol issue, SASL, etc. *) certs are fully validated - valid root certs must be available. This is a hassle, but it means that you *can* trust the identity of the server. *) the client library can handle hardcoded root certificates, to avoid the need to copy these files. *) host name of server cert must resolve to IP address, or be a recognized alias. This is more liberal than the previous iteration. *) the number of bytes transferred is tracked, and the session key is periodically renegotiated. *) basic cert generation scripts (mkcert.sh, pgkeygen.sh). The configuration files have reasonable defaults for each type of use.Bear Giles1 parent15378a5 commita9bd176
File tree
15 files changed
+1562
-208
lines changed- src
- backend
- libpq
- postmaster
- bin/psql
- include/libpq
- interfaces
- libpq
- ssl
15 files changed
+1562
-208
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
84 | 92 | | |
85 | 93 | | |
86 | 94 | | |
| |||
138 | 146 | | |
139 | 147 | | |
140 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
141 | 152 | | |
142 | 153 | | |
143 | 154 | | |
| |||
416 | 427 | | |
417 | 428 | | |
418 | 429 | | |
| 430 | + | |
419 | 431 | | |
420 | 432 | | |
421 | 433 | | |
| |||
457 | 469 | | |
458 | 470 | | |
459 | 471 | | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
| 472 | + | |
| 473 | + | |
468 | 474 | | |
469 | 475 | | |
470 | 476 | | |
| |||
480 | 486 | | |
481 | 487 | | |
482 | 488 | | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
483 | 492 | | |
| 493 | + | |
484 | 494 | | |
485 | 495 | | |
486 | 496 | | |
| |||
651 | 661 | | |
652 | 662 | | |
653 | 663 | | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
| 664 | + | |
660 | 665 | | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
661 | 669 | | |
| 670 | + | |
662 | 671 | | |
663 | 672 | | |
664 | 673 | | |
| |||
703 | 712 | | |
704 | 713 | | |
705 | 714 | | |
706 | | - | |
| 715 | + | |
707 | 716 | | |
| 717 | + | |
708 | 718 | | |
709 | 719 | | |
710 | 720 | | |
| |||
713 | 723 | | |
714 | 724 | | |
715 | 725 | | |
| 726 | + | |
| 727 | + | |
716 | 728 | | |
717 | 729 | | |
718 | 730 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | 168 | | |
173 | 169 | | |
174 | 170 | | |
| |||
274 | 270 | | |
275 | 271 | | |
276 | 272 | | |
277 | | - | |
278 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
279 | 277 | | |
280 | 278 | | |
281 | 279 | | |
| |||
609 | 607 | | |
610 | 608 | | |
611 | 609 | | |
612 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
613 | 614 | | |
614 | 615 | | |
615 | 616 | | |
| |||
1114 | 1115 | | |
1115 | 1116 | | |
1116 | 1117 | | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
| 1118 | + | |
| 1119 | + | |
1121 | 1120 | | |
1122 | | - | |
1123 | | - | |
1124 | 1121 | | |
1125 | 1122 | | |
1126 | 1123 | | |
| |||
1322 | 1319 | | |
1323 | 1320 | | |
1324 | 1321 | | |
1325 | | - | |
1326 | | - | |
| 1322 | + | |
1327 | 1323 | | |
| 1324 | + | |
| 1325 | + | |
1328 | 1326 | | |
1329 | 1327 | | |
1330 | 1328 | | |
| |||
2424 | 2422 | | |
2425 | 2423 | | |
2426 | 2424 | | |
2427 | | - | |
2428 | | - | |
2429 | | - | |
2430 | | - | |
2431 | | - | |
2432 | | - | |
2433 | | - | |
2434 | | - | |
2435 | | - | |
2436 | | - | |
2437 | | - | |
2438 | | - | |
2439 | | - | |
2440 | | - | |
2441 | | - | |
2442 | | - | |
2443 | | - | |
2444 | | - | |
2445 | | - | |
2446 | | - | |
2447 | | - | |
2448 | | - | |
2449 | | - | |
2450 | | - | |
2451 | | - | |
2452 | | - | |
2453 | | - | |
2454 | | - | |
2455 | | - | |
2456 | | - | |
2457 | | - | |
2458 | | - | |
2459 | | - | |
2460 | | - | |
2461 | | - | |
2462 | | - | |
2463 | | - | |
2464 | | - | |
2465 | | - | |
2466 | | - | |
2467 | | - | |
2468 | | - | |
2469 | | - | |
2470 | | - | |
2471 | | - | |
2472 | | - | |
2473 | | - | |
2474 | | - | |
2475 | | - | |
2476 | | - | |
2477 | | - | |
2478 | | - | |
2479 | | - | |
2480 | | - | |
2481 | | - | |
2482 | | - | |
2483 | | - | |
2484 | | - | |
2485 | | - | |
2486 | | - | |
2487 | | - | |
2488 | | - | |
2489 | | - | |
2490 | | - | |
2491 | | - | |
2492 | | - | |
2493 | 2425 | | |
2494 | 2426 | | |
2495 | 2427 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
681 | 684 | | |
682 | 685 | | |
683 | 686 | | |
684 | 687 | | |
685 | 688 | | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
686 | 701 | | |
687 | | - | |
| 702 | + | |
| 703 | + | |
688 | 704 | | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
689 | 708 | | |
690 | 709 | | |
691 | 710 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
0 commit comments
Comments
(0)