Mercurial > emacs
annotate src/gnutls.c @ 110776:073caec7510f
* net/tramp.el (tramp-handle-directory-files-and-attributes)
(tramp-handle-file-exists-p, tramp-handle-file-newer-than-file-p):
New defuns, taken from tramp-smb.el.
(tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag): Removed.
* net/tramp-compat.el (top): Do not check for byte-compiler
objects.
(tramp-compat-coding-system-change-eol-conversion)
(tramp-compat-set-process-query-on-exit-flag): New defuns, taken
from tramp.el.
* net/tramp-gvfs.el:
* net/tramp-gw.el: Replace `tramp-set-process-query-on-exit-flag'
by `tramp-compat-set-process-query-on-exit-flag'.
* net/tramp-imap.el (tramp-imap-file-name-handler-alist): Use
`tramp-handle-directory-files-and-attributes',
`tramp-handle-file-exists-p' and
`tramp-handle-file-newer-than-file-p'.
(tramp-imap-handle-file-exists-p)
(tramp-imap-handle-file-executable-p)
(tramp-imap-handle-file-readable-p)
(tramp-imap-handle-directory-files-and-attributes)
(tramp-imap-handle-file-newer-than-file-p): Removed.
* net/tramp-sh.el: Replace `tramp-set-process-query-on-exit-flag'
by `tramp-compat-set-process-query-on-exit-flag' and
`tramp-coding-system-change-eol-conversion' by
`tramp-compat-coding-system-change-eol-conversion'.
* net/tramp-smb.el (tramp-smb-file-name-handler-alist): Use
`tramp-handle-directory-files-and-attributes',
`tramp-handle-file-exists-p' and
`tramp-handle-file-newer-than-file-p'.
(tramp-smb-handle-directory-files-and-attributes)
(tramp-smb-handle-file-exists-p)
(tramp-smb-handle-file-newer-than-file-p): Removed.
(tramp-smb-maybe-open-connection): Replace
`tramp-set-process-query-on-exit-flag' by
`tramp-compat-set-process-query-on-exit-flag'.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Tue, 05 Oct 2010 16:20:24 +0200 |
parents | af2db97ca17a |
children | bb9bf961ba7b |
rev | line source |
---|---|
110584 | 1 /* GnuTLS glue for GNU Emacs. |
2 Copyright (C) 2010 Free Software Foundation, Inc. | |
3 | |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software: you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation, either version 3 of the License, or | |
9 (at your option) any later version. | |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |
18 | |
19 #include <config.h> | |
20 #include <errno.h> | |
21 #include <setjmp.h> | |
22 | |
23 #include "lisp.h" | |
24 #include "process.h" | |
25 | |
26 #ifdef HAVE_GNUTLS | |
27 #include <gnutls/gnutls.h> | |
28 | |
29 Lisp_Object Qgnutls_code; | |
30 Lisp_Object Qgnutls_anon, Qgnutls_x509pki; | |
31 Lisp_Object Qgnutls_e_interrupted, Qgnutls_e_again, | |
32 Qgnutls_e_invalid_session, Qgnutls_e_not_ready_for_handshake; | |
33 int global_initialized; | |
34 | |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
35 /* The following are for the property list of `gnutls-boot'. */ |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
36 Lisp_Object Qgnutls_bootprop_priority; |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
37 Lisp_Object Qgnutls_bootprop_trustfiles; |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
38 Lisp_Object Qgnutls_bootprop_keyfiles; |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
39 Lisp_Object Qgnutls_bootprop_callbacks; |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
40 Lisp_Object Qgnutls_bootprop_loglevel; |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
41 |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
42 static void |
110649
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
43 emacs_gnutls_handshake (struct Lisp_Process *proc) |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
44 { |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
45 gnutls_session_t state = proc->gnutls_state; |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
46 int ret; |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
47 |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
48 if (proc->gnutls_initstage < GNUTLS_STAGE_HANDSHAKE_CANDO) |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
49 return; |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
50 |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
51 if (proc->gnutls_initstage < GNUTLS_STAGE_TRANSPORT_POINTERS_SET) |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
52 { |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
53 /* This is how GnuTLS takes sockets: as file descriptors passed |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
54 in. For an Emacs process socket, infd and outfd are the |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
55 same but we use this two-argument version for clarity. */ |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
56 gnutls_transport_set_ptr2 (state, |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
57 (gnutls_transport_ptr_t) (long) proc->infd, |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
58 (gnutls_transport_ptr_t) (long) proc->outfd); |
110649
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
59 |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
60 proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
61 } |
110649
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
62 |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
63 ret = gnutls_handshake (state); |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
64 proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
65 |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
66 if (ret == GNUTLS_E_SUCCESS) |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
67 { |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
68 /* here we're finally done. */ |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
69 proc->gnutls_initstage = GNUTLS_STAGE_READY; |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
70 } |
110649
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
71 } |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
72 |
110584 | 73 int |
110648
256dd50b2a63
Make sure all reads/writes to gnutls streams go via the gnutls functions.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110636
diff
changeset
|
74 emacs_gnutls_write (int fildes, struct Lisp_Process *proc, char *buf, |
110584 | 75 unsigned int nbyte) |
76 { | |
77 register int rtnval, bytes_written; | |
110648
256dd50b2a63
Make sure all reads/writes to gnutls streams go via the gnutls functions.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110636
diff
changeset
|
78 gnutls_session_t state = proc->gnutls_state; |
256dd50b2a63
Make sure all reads/writes to gnutls streams go via the gnutls functions.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110636
diff
changeset
|
79 |
256dd50b2a63
Make sure all reads/writes to gnutls streams go via the gnutls functions.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110636
diff
changeset
|
80 if (proc->gnutls_initstage != GNUTLS_STAGE_READY) |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
81 return -1; |
110584 | 82 |
83 bytes_written = 0; | |
84 | |
85 while (nbyte > 0) | |
86 { | |
87 rtnval = gnutls_write (state, buf, nbyte); | |
88 | |
89 if (rtnval == -1) | |
90 { | |
91 if (errno == EINTR) | |
92 continue; | |
93 else | |
94 return (bytes_written ? bytes_written : -1); | |
95 } | |
96 | |
97 buf += rtnval; | |
98 nbyte -= rtnval; | |
99 bytes_written += rtnval; | |
100 } | |
101 fsync (STDOUT_FILENO); | |
102 | |
103 return (bytes_written); | |
104 } | |
105 | |
106 int | |
110648
256dd50b2a63
Make sure all reads/writes to gnutls streams go via the gnutls functions.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110636
diff
changeset
|
107 emacs_gnutls_read (int fildes, struct Lisp_Process *proc, char *buf, |
110584 | 108 unsigned int nbyte) |
109 { | |
110 register int rtnval; | |
110648
256dd50b2a63
Make sure all reads/writes to gnutls streams go via the gnutls functions.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110636
diff
changeset
|
111 gnutls_session_t state = proc->gnutls_state; |
256dd50b2a63
Make sure all reads/writes to gnutls streams go via the gnutls functions.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110636
diff
changeset
|
112 |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
113 if (proc->gnutls_initstage != GNUTLS_STAGE_READY) |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
114 { |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
115 emacs_gnutls_handshake (proc); |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
116 return -1; |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
117 } |
110584 | 118 |
110608
06497cf3e920
(emacs_gnutls_read): Don't infloop while reading.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110606
diff
changeset
|
119 rtnval = gnutls_read (state, buf, nbyte); |
06497cf3e920
(emacs_gnutls_read): Don't infloop while reading.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110606
diff
changeset
|
120 if (rtnval >= 0) |
06497cf3e920
(emacs_gnutls_read): Don't infloop while reading.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110606
diff
changeset
|
121 return rtnval; |
06497cf3e920
(emacs_gnutls_read): Don't infloop while reading.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110606
diff
changeset
|
122 else |
110648
256dd50b2a63
Make sure all reads/writes to gnutls streams go via the gnutls functions.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110636
diff
changeset
|
123 return 0; |
110584 | 124 } |
125 | |
126 /* convert an integer error to a Lisp_Object; it will be either a | |
127 known symbol like `gnutls_e_interrupted' and `gnutls_e_again' or | |
128 simply the integer value of the error. GNUTLS_E_SUCCESS is mapped | |
129 to Qt. */ | |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
130 static Lisp_Object |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
131 gnutls_make_error (int error) |
110584 | 132 { |
133 switch (error) | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
134 { |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
135 case GNUTLS_E_SUCCESS: |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
136 return Qt; |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
137 case GNUTLS_E_AGAIN: |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
138 return Qgnutls_e_again; |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
139 case GNUTLS_E_INTERRUPTED: |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
140 return Qgnutls_e_interrupted; |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
141 case GNUTLS_E_INVALID_SESSION: |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
142 return Qgnutls_e_invalid_session; |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
143 } |
110584 | 144 |
145 return make_number (error); | |
146 } | |
147 | |
148 DEFUN ("gnutls-get-initstage", Fgnutls_get_initstage, Sgnutls_get_initstage, 1, 1, 0, | |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
149 doc: /* Return the GnuTLS init stage of process PROC. |
110584 | 150 See also `gnutls-boot'. */) |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
151 (Lisp_Object proc) |
110584 | 152 { |
153 CHECK_PROCESS (proc); | |
154 | |
155 return make_number (GNUTLS_INITSTAGE (proc)); | |
156 } | |
157 | |
158 DEFUN ("gnutls-errorp", Fgnutls_errorp, Sgnutls_errorp, 1, 1, 0, | |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
159 doc: /* Return t if ERROR indicates a GnuTLS problem. |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
160 ERROR is an integer or a symbol with an integer `gnutls-code' property. |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
161 usage: (gnutls-errorp ERROR) */) |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
162 (Lisp_Object err) |
110584 | 163 { |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
164 if (EQ (err, Qt)) return Qnil; |
110584 | 165 |
166 return Qt; | |
167 } | |
168 | |
169 DEFUN ("gnutls-error-fatalp", Fgnutls_error_fatalp, Sgnutls_error_fatalp, 1, 1, 0, | |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
170 doc: /* Check if ERROR is fatal. |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
171 ERROR is an integer or a symbol with an integer `gnutls-code' property. |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
172 usage: (gnutls-error-fatalp ERROR) */) |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
173 (Lisp_Object err) |
110584 | 174 { |
175 Lisp_Object code; | |
176 | |
177 if (EQ (err, Qt)) return Qnil; | |
178 | |
179 if (SYMBOLP (err)) | |
180 { | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
181 code = Fget (err, Qgnutls_code); |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
182 if (NUMBERP (code)) |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
183 { |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
184 err = code; |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
185 } |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
186 else |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
187 { |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
188 error ("Symbol has no numeric gnutls-code property"); |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
189 } |
110584 | 190 } |
191 | |
192 if (!NUMBERP (err)) | |
193 error ("Not an error symbol or code"); | |
194 | |
195 if (0 == gnutls_error_is_fatal (XINT (err))) | |
196 return Qnil; | |
197 | |
198 return Qt; | |
199 } | |
200 | |
201 DEFUN ("gnutls-error-string", Fgnutls_error_string, Sgnutls_error_string, 1, 1, 0, | |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
202 doc: /* Return a description of ERROR. |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
203 ERROR is an integer or a symbol with an integer `gnutls-code' property. |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
204 usage: (gnutls-error-string ERROR) */) |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
205 (Lisp_Object err) |
110584 | 206 { |
207 Lisp_Object code; | |
208 | |
209 if (EQ (err, Qt)) return build_string ("Not an error"); | |
210 | |
211 if (SYMBOLP (err)) | |
212 { | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
213 code = Fget (err, Qgnutls_code); |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
214 if (NUMBERP (code)) |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
215 { |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
216 err = code; |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
217 } |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
218 else |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
219 { |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
220 return build_string ("Symbol has no numeric gnutls-code property"); |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
221 } |
110584 | 222 } |
223 | |
224 if (!NUMBERP (err)) | |
225 return build_string ("Not an error symbol or code"); | |
226 | |
227 return build_string (gnutls_strerror (XINT (err))); | |
228 } | |
229 | |
230 DEFUN ("gnutls-deinit", Fgnutls_deinit, Sgnutls_deinit, 1, 1, 0, | |
110728
ab7396ada96a
src/gnutls.c: Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
110724
diff
changeset
|
231 doc: /* Deallocate GnuTLS resources associated with process PROC. |
110584 | 232 See also `gnutls-init'. */) |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
233 (Lisp_Object proc) |
110584 | 234 { |
235 gnutls_session_t state; | |
236 | |
237 CHECK_PROCESS (proc); | |
238 state = XPROCESS (proc)->gnutls_state; | |
239 | |
240 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
241 { |
110584 | 242 gnutls_deinit (state); |
243 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1; | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
244 } |
110584 | 245 |
246 return Qt; | |
247 } | |
248 | |
110728
ab7396ada96a
src/gnutls.c: Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
110724
diff
changeset
|
249 /* Initializes global GnuTLS state to defaults. |
ab7396ada96a
src/gnutls.c: Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
110724
diff
changeset
|
250 Call `gnutls-global-deinit' when GnuTLS usage is no longer needed. |
110584 | 251 Returns zero on success. */ |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
252 static Lisp_Object |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
253 gnutls_emacs_global_init (void) |
110584 | 254 { |
255 int ret = GNUTLS_E_SUCCESS; | |
256 | |
257 if (!global_initialized) | |
258 ret = gnutls_global_init (); | |
259 | |
260 global_initialized = 1; | |
261 | |
262 return gnutls_make_error (ret); | |
263 } | |
264 | |
110728
ab7396ada96a
src/gnutls.c: Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
110724
diff
changeset
|
265 /* Deinitializes global GnuTLS state. |
110584 | 266 See also `gnutls-global-init'. */ |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
267 static Lisp_Object |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
268 gnutls_emacs_global_deinit (void) |
110584 | 269 { |
270 if (global_initialized) | |
271 gnutls_global_deinit (); | |
272 | |
273 global_initialized = 0; | |
274 | |
275 return gnutls_make_error (GNUTLS_E_SUCCESS); | |
276 } | |
277 | |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
278 static void |
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
279 gnutls_log_function (int level, const char* string) |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
280 { |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
281 message ("gnutls.c: [%d] %s", level, string); |
110606
b4f4c3e9b976
Add debugging to the gnutls library, and finish handshaking when it's done.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110584
diff
changeset
|
282 } |
b4f4c3e9b976
Add debugging to the gnutls library, and finish handshaking when it's done.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110584
diff
changeset
|
283 |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
284 static void |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
285 gnutls_log_function2 (int level, const char* string, const char* extra) |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
286 { |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
287 message ("gnutls.c: [%d] %s %s", level, string, extra); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
288 } |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
289 |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
290 DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
291 doc: /* Initialize GnuTLS client for process PROC with TYPE+PROPLIST. |
110584 | 292 Currently only client mode is supported. Returns a success/failure |
293 value you can check with `gnutls-errorp'. | |
294 | |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
295 TYPE is a symbol, either `gnutls-anon' or `gnutls-x509pki'. |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
296 PROPLIST is a property list with the following keys: |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
297 |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
298 :priority is a GnuTLS priority string, defaults to "NORMAL". |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
299 :trustfiles is a list of PEM-encoded trust files for `gnutls-x509pki'. |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
300 :keyfiles is a list of PEM-encoded key files for `gnutls-x509pki'. |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
301 :callbacks is an alist of callback functions (TODO). |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
302 :loglevel is the debug level requested from GnuTLS, try 4. |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
303 |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
304 The debug level will be set for this process AND globally for GnuTLS. |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
305 So if you set it higher or lower at any point, it affects global |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
306 debugging. |
110584 | 307 |
308 Note that the priority is set on the client. The server does not use | |
309 the protocols's priority except for disabling protocols that were not | |
310 specified. | |
311 | |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
312 Processes must be initialized with this function before other GnuTLS |
110584 | 313 functions are used. This function allocates resources which can only |
314 be deallocated by calling `gnutls-deinit' or by calling it again. | |
315 | |
316 Each authentication type may need additional information in order to | |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
317 work. For X.509 PKI (`gnutls-x509pki'), you probably need at least |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
318 one trustfile (usually a CA bundle). */) |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
319 (Lisp_Object proc, Lisp_Object type, Lisp_Object proplist) |
110584 | 320 { |
321 int ret = GNUTLS_E_SUCCESS; | |
322 | |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
323 int max_log_level = 0; |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
324 |
110584 | 325 /* TODO: GNUTLS_X509_FMT_DER is also an option. */ |
326 int file_format = GNUTLS_X509_FMT_PEM; | |
327 | |
328 gnutls_session_t state; | |
329 gnutls_certificate_credentials_t x509_cred; | |
330 gnutls_anon_client_credentials_t anon_cred; | |
331 Lisp_Object global_init; | |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
332 char* priority_string_ptr = "NORMAL"; /* default priority string. */ |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
333 Lisp_Object tail; |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
334 |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
335 /* Placeholders for the property list elements. */ |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
336 Lisp_Object priority_string; |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
337 Lisp_Object trustfiles; |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
338 Lisp_Object keyfiles; |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
339 Lisp_Object callbacks; |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
340 Lisp_Object loglevel; |
110584 | 341 |
342 CHECK_PROCESS (proc); | |
343 CHECK_SYMBOL (type); | |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
344 CHECK_LIST (proplist); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
345 |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
346 priority_string = Fplist_get (proplist, Qgnutls_bootprop_priority); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
347 trustfiles = Fplist_get (proplist, Qgnutls_bootprop_trustfiles); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
348 keyfiles = Fplist_get (proplist, Qgnutls_bootprop_keyfiles); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
349 callbacks = Fplist_get (proplist, Qgnutls_bootprop_callbacks); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
350 loglevel = Fplist_get (proplist, Qgnutls_bootprop_loglevel); |
110584 | 351 |
352 state = XPROCESS (proc)->gnutls_state; | |
110648
256dd50b2a63
Make sure all reads/writes to gnutls streams go via the gnutls functions.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110636
diff
changeset
|
353 XPROCESS (proc)->gnutls_p = 1; |
110584 | 354 |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
355 if (NUMBERP (loglevel)) |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
356 { |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
357 gnutls_global_set_log_function (gnutls_log_function); |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
358 gnutls_global_set_log_level (XINT (loglevel)); |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
359 max_log_level = XINT (loglevel); |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
360 XPROCESS (proc)->gnutls_log_level = max_log_level; |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
361 } |
110648
256dd50b2a63
Make sure all reads/writes to gnutls streams go via the gnutls functions.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110636
diff
changeset
|
362 |
110584 | 363 /* always initialize globals. */ |
364 global_init = gnutls_emacs_global_init (); | |
365 if (! NILP (Fgnutls_errorp (global_init))) | |
366 return global_init; | |
367 | |
368 /* deinit and free resources. */ | |
369 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_CRED_ALLOC) | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
370 { |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
371 GNUTLS_LOG (1, max_log_level, "deallocating credentials"); |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
372 |
110584 | 373 if (EQ (type, Qgnutls_x509pki)) |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
374 { |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
375 GNUTLS_LOG (2, max_log_level, "deallocating x509 credentials"); |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
376 x509_cred = XPROCESS (proc)->gnutls_x509_cred; |
110584 | 377 gnutls_certificate_free_credentials (x509_cred); |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
378 } |
110584 | 379 else if (EQ (type, Qgnutls_anon)) |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
380 { |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
381 GNUTLS_LOG (2, max_log_level, "deallocating anon credentials"); |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
382 anon_cred = XPROCESS (proc)->gnutls_anon_cred; |
110584 | 383 gnutls_anon_free_client_credentials (anon_cred); |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
384 } |
110584 | 385 else |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
386 { |
110584 | 387 error ("unknown credential type"); |
388 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE; | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
389 } |
110584 | 390 |
391 if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
392 { |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
393 GNUTLS_LOG (1, max_log_level, "deallocating x509 credentials"); |
110584 | 394 Fgnutls_deinit (proc); |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
395 } |
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
396 } |
110584 | 397 |
398 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_EMPTY; | |
399 | |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
400 GNUTLS_LOG (1, max_log_level, "allocating credentials"); |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
401 |
110584 | 402 if (EQ (type, Qgnutls_x509pki)) |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
403 { |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
404 GNUTLS_LOG (2, max_log_level, "allocating x509 credentials"); |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
405 x509_cred = XPROCESS (proc)->gnutls_x509_cred; |
110584 | 406 if (gnutls_certificate_allocate_credentials (&x509_cred) < 0) |
407 memory_full (); | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
408 } |
110584 | 409 else if (EQ (type, Qgnutls_anon)) |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
410 { |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
411 GNUTLS_LOG (2, max_log_level, "allocating anon credentials"); |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
412 anon_cred = XPROCESS (proc)->gnutls_anon_cred; |
110584 | 413 if (gnutls_anon_allocate_client_credentials (&anon_cred) < 0) |
414 memory_full (); | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
415 } |
110584 | 416 else |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
417 { |
110584 | 418 error ("unknown credential type"); |
419 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE; | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
420 } |
110584 | 421 |
422 if (ret < GNUTLS_E_SUCCESS) | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
423 return gnutls_make_error (ret); |
110584 | 424 |
425 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_ALLOC; | |
426 | |
427 if (EQ (type, Qgnutls_x509pki)) | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
428 { |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
429 for (tail = trustfiles; !NILP (tail); tail = Fcdr (tail)) |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
430 { |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
431 Lisp_Object trustfile = Fcar (tail); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
432 if (STRINGP (trustfile)) |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
433 { |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
434 GNUTLS_LOG2 (1, max_log_level, "setting the trustfile: ", |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
435 SDATA (trustfile)); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
436 ret = gnutls_certificate_set_x509_trust_file |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
437 (x509_cred, |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
438 SDATA (trustfile), |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
439 file_format); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
440 |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
441 if (ret < GNUTLS_E_SUCCESS) |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
442 return gnutls_make_error (ret); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
443 } |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
444 else |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
445 { |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
446 error ("Sorry, GnuTLS can't use non-string trustfile %s", |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
447 trustfile); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
448 } |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
449 } |
110584 | 450 |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
451 for (tail = keyfiles; !NILP (tail); tail = Fcdr (tail)) |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
452 { |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
453 Lisp_Object keyfile = Fcar (tail); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
454 if (STRINGP (keyfile)) |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
455 { |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
456 GNUTLS_LOG2 (1, max_log_level, "setting the keyfile: ", |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
457 SDATA (keyfile)); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
458 ret = gnutls_certificate_set_x509_crl_file |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
459 (x509_cred, |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
460 SDATA (keyfile), |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
461 file_format); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
462 |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
463 if (ret < GNUTLS_E_SUCCESS) |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
464 return gnutls_make_error (ret); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
465 } |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
466 else |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
467 { |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
468 error ("Sorry, GnuTLS can't use non-string keyfile %s", |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
469 keyfile); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
470 } |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
471 } |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
472 } |
110584 | 473 |
474 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES; | |
475 | |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
476 GNUTLS_LOG (1, max_log_level, "gnutls_init"); |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
477 |
110584 | 478 ret = gnutls_init (&state, GNUTLS_CLIENT); |
479 | |
480 if (ret < GNUTLS_E_SUCCESS) | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
481 return gnutls_make_error (ret); |
110584 | 482 |
483 XPROCESS (proc)->gnutls_state = state; | |
484 | |
485 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT; | |
486 | |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
487 if (STRINGP (priority_string)) |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
488 { |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
489 priority_string_ptr = (char*) SDATA (priority_string); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
490 GNUTLS_LOG2 (1, max_log_level, "got non-default priority string:", |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
491 priority_string_ptr); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
492 } |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
493 else |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
494 { |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
495 GNUTLS_LOG2 (1, max_log_level, "using default priority string:", |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
496 priority_string_ptr); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
497 } |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
498 |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
499 GNUTLS_LOG (1, max_log_level, "setting the priority string"); |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
500 |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
501 ret = gnutls_priority_set_direct (state, |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
502 priority_string_ptr, |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
503 NULL); |
110584 | 504 |
505 if (ret < GNUTLS_E_SUCCESS) | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
506 return gnutls_make_error (ret); |
110584 | 507 |
508 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_PRIORITY; | |
509 | |
510 if (EQ (type, Qgnutls_x509pki)) | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
511 { |
110584 | 512 ret = gnutls_cred_set (state, GNUTLS_CRD_CERTIFICATE, x509_cred); |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
513 } |
110584 | 514 else if (EQ (type, Qgnutls_anon)) |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
515 { |
110584 | 516 ret = gnutls_cred_set (state, GNUTLS_CRD_ANON, anon_cred); |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
517 } |
110584 | 518 else |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
519 { |
110584 | 520 error ("unknown credential type"); |
521 ret = GNUTLS_EMACS_ERROR_INVALID_TYPE; | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
522 } |
110584 | 523 |
524 if (ret < GNUTLS_E_SUCCESS) | |
110652
056ce44cedcd
Clean up gnutls.c coding style to conform with the Emacs style.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110649
diff
changeset
|
525 return gnutls_make_error (ret); |
110584 | 526 |
110611
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
527 XPROCESS (proc)->gnutls_anon_cred = anon_cred; |
6c735824d0c1
Add gnutls logging and clean up various gnutls bits.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110608
diff
changeset
|
528 XPROCESS (proc)->gnutls_x509_cred = x509_cred; |
110584 | 529 XPROCESS (proc)->gnutls_cred_type = type; |
530 | |
531 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET; | |
532 | |
110649
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
533 emacs_gnutls_handshake (XPROCESS (proc)); |
2f0d755fa21b
Do the gnutls handshake from the reader loop, instead of looping over
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110648
diff
changeset
|
534 |
110584 | 535 return gnutls_make_error (GNUTLS_E_SUCCESS); |
536 } | |
537 | |
538 DEFUN ("gnutls-bye", Fgnutls_bye, | |
539 Sgnutls_bye, 2, 2, 0, | |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
540 doc: /* Terminate current GnuTLS connection for process PROC. |
110584 | 541 The connection should have been initiated using `gnutls-handshake'. |
542 | |
543 If CONT is not nil the TLS connection gets terminated and further | |
110724
3ccf1931ae33
src/gnutls.c: Doc fixes. Make some functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110652
diff
changeset
|
544 receives and sends will be disallowed. If the return value is zero you |
110584 | 545 may continue using the connection. If CONT is nil, GnuTLS actually |
546 sends an alert containing a close request and waits for the peer to | |
547 reply with the same message. In order to reuse the connection you | |
548 should wait for an EOF from the peer. | |
549 | |
550 This function may also return `gnutls-e-again', or | |
551 `gnutls-e-interrupted'. */) | |
552 (Lisp_Object proc, Lisp_Object cont) | |
553 { | |
554 gnutls_session_t state; | |
555 int ret; | |
556 | |
557 CHECK_PROCESS (proc); | |
558 | |
559 state = XPROCESS (proc)->gnutls_state; | |
560 | |
561 ret = gnutls_bye (state, | |
562 NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR); | |
563 | |
564 return gnutls_make_error (ret); | |
565 } | |
566 | |
567 void | |
568 syms_of_gnutls (void) | |
569 { | |
570 global_initialized = 0; | |
571 | |
572 Qgnutls_code = intern_c_string ("gnutls-code"); | |
573 staticpro (&Qgnutls_code); | |
574 | |
575 Qgnutls_anon = intern_c_string ("gnutls-anon"); | |
576 staticpro (&Qgnutls_anon); | |
577 | |
578 Qgnutls_x509pki = intern_c_string ("gnutls-x509pki"); | |
579 staticpro (&Qgnutls_x509pki); | |
580 | |
110745
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
581 Qgnutls_bootprop_priority = intern_c_string ("priority"); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
582 staticpro (&Qgnutls_bootprop_priority); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
583 |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
584 Qgnutls_bootprop_trustfiles = intern_c_string ("trustfiles"); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
585 staticpro (&Qgnutls_bootprop_trustfiles); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
586 |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
587 Qgnutls_bootprop_keyfiles = intern_c_string ("keyfiles"); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
588 staticpro (&Qgnutls_bootprop_keyfiles); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
589 |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
590 Qgnutls_bootprop_callbacks = intern_c_string ("callbacks"); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
591 staticpro (&Qgnutls_bootprop_callbacks); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
592 |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
593 Qgnutls_bootprop_loglevel = intern_c_string ("loglevel"); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
594 staticpro (&Qgnutls_bootprop_loglevel); |
af2db97ca17a
Rework the gnutls boot interface.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
110728
diff
changeset
|
595 |
110584 | 596 Qgnutls_e_interrupted = intern_c_string ("gnutls-e-interrupted"); |
597 staticpro (&Qgnutls_e_interrupted); | |
598 Fput (Qgnutls_e_interrupted, Qgnutls_code, | |
599 make_number (GNUTLS_E_INTERRUPTED)); | |
600 | |
601 Qgnutls_e_again = intern_c_string ("gnutls-e-again"); | |
602 staticpro (&Qgnutls_e_again); | |
603 Fput (Qgnutls_e_again, Qgnutls_code, | |
604 make_number (GNUTLS_E_AGAIN)); | |
605 | |
606 Qgnutls_e_invalid_session = intern_c_string ("gnutls-e-invalid-session"); | |
607 staticpro (&Qgnutls_e_invalid_session); | |
608 Fput (Qgnutls_e_invalid_session, Qgnutls_code, | |
609 make_number (GNUTLS_E_INVALID_SESSION)); | |
610 | |
611 Qgnutls_e_not_ready_for_handshake = | |
612 intern_c_string ("gnutls-e-not-ready-for-handshake"); | |
613 staticpro (&Qgnutls_e_not_ready_for_handshake); | |
614 Fput (Qgnutls_e_not_ready_for_handshake, Qgnutls_code, | |
615 make_number (GNUTLS_E_APPLICATION_ERROR_MIN)); | |
616 | |
617 defsubr (&Sgnutls_get_initstage); | |
618 defsubr (&Sgnutls_errorp); | |
619 defsubr (&Sgnutls_error_fatalp); | |
620 defsubr (&Sgnutls_error_string); | |
621 defsubr (&Sgnutls_boot); | |
622 defsubr (&Sgnutls_deinit); | |
623 defsubr (&Sgnutls_bye); | |
624 } | |
625 #endif |