~ubuntu-branches/ubuntu/trusty/ocamlnet/trusty

« back to all changes in this revision

Viewing changes to doc/html-main/Rpc_intro_gss.html

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu
  • Date: 2011-09-02 14:12:33 UTC
  • mfrom: (18.2.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110902141233-zbj0ygxb92u6gy4z
Tags: 3.4-1
* New upstream release
  - add a new NetcgiRequire directive to ease dependency management
    (Closes: #637147)
  - remove patches that were applied upstream:
    + Added-missing-shebang-lines-in-example-shell-scripts
    + Try-also-ocamlc-for-POSIX-threads

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
2
<html>
 
3
<head>
 
4
<link rel="stylesheet" href="style.css" type="text/css">
 
5
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
 
6
<link rel="Start" href="index.html">
 
7
<link rel="previous" href="Rpc_mapping_ref.html">
 
8
<link rel="next" href="Shell_sys.html">
 
9
<link rel="Up" href="index.html">
 
10
<link title="Index of types" rel=Appendix href="index_types.html">
 
11
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
 
12
<link title="Index of values" rel=Appendix href="index_values.html">
 
13
<link title="Index of class attributes" rel=Appendix href="index_attributes.html">
 
14
<link title="Index of class methods" rel=Appendix href="index_methods.html">
 
15
<link title="Index of classes" rel=Appendix href="index_classes.html">
 
16
<link title="Index of class types" rel=Appendix href="index_class_types.html">
 
17
<link title="Index of modules" rel=Appendix href="index_modules.html">
 
18
<link title="Index of module types" rel=Appendix href="index_module_types.html">
 
19
<link title="Uq_gtk" rel="Chapter" href="Uq_gtk.html">
 
20
<link title="Uq_ssl" rel="Chapter" href="Uq_ssl.html">
 
21
<link title="Https_client" rel="Chapter" href="Https_client.html">
 
22
<link title="Uq_tcl" rel="Chapter" href="Uq_tcl.html">
 
23
<link title="Equeue" rel="Chapter" href="Equeue.html">
 
24
<link title="Unixqueue" rel="Chapter" href="Unixqueue.html">
 
25
<link title="Unixqueue_pollset" rel="Chapter" href="Unixqueue_pollset.html">
 
26
<link title="Unixqueue_select" rel="Chapter" href="Unixqueue_select.html">
 
27
<link title="Uq_resolver" rel="Chapter" href="Uq_resolver.html">
 
28
<link title="Uq_engines" rel="Chapter" href="Uq_engines.html">
 
29
<link title="Uq_socks5" rel="Chapter" href="Uq_socks5.html">
 
30
<link title="Uq_io" rel="Chapter" href="Uq_io.html">
 
31
<link title="Uq_lwt" rel="Chapter" href="Uq_lwt.html">
 
32
<link title="Uq_libevent" rel="Chapter" href="Uq_libevent.html">
 
33
<link title="Equeue_intro" rel="Chapter" href="Equeue_intro.html">
 
34
<link title="Netcamlbox" rel="Chapter" href="Netcamlbox.html">
 
35
<link title="Netcgi_apache" rel="Chapter" href="Netcgi_apache.html">
 
36
<link title="Netcgi_modtpl" rel="Chapter" href="Netcgi_modtpl.html">
 
37
<link title="Netcgi_plex" rel="Chapter" href="Netcgi_plex.html">
 
38
<link title="Netcgi_common" rel="Chapter" href="Netcgi_common.html">
 
39
<link title="Netcgi" rel="Chapter" href="Netcgi.html">
 
40
<link title="Netcgi_ajp" rel="Chapter" href="Netcgi_ajp.html">
 
41
<link title="Netcgi_scgi" rel="Chapter" href="Netcgi_scgi.html">
 
42
<link title="Netcgi_cgi" rel="Chapter" href="Netcgi_cgi.html">
 
43
<link title="Netcgi_fcgi" rel="Chapter" href="Netcgi_fcgi.html">
 
44
<link title="Netcgi_dbi" rel="Chapter" href="Netcgi_dbi.html">
 
45
<link title="Netcgi1_compat" rel="Chapter" href="Netcgi1_compat.html">
 
46
<link title="Netcgi_test" rel="Chapter" href="Netcgi_test.html">
 
47
<link title="Netcgi_porting" rel="Chapter" href="Netcgi_porting.html">
 
48
<link title="Http_client_conncache" rel="Chapter" href="Http_client_conncache.html">
 
49
<link title="Http_client" rel="Chapter" href="Http_client.html">
 
50
<link title="Telnet_client" rel="Chapter" href="Telnet_client.html">
 
51
<link title="Ftp_data_endpoint" rel="Chapter" href="Ftp_data_endpoint.html">
 
52
<link title="Ftp_client" rel="Chapter" href="Ftp_client.html">
 
53
<link title="Http_fs" rel="Chapter" href="Http_fs.html">
 
54
<link title="Ftp_fs" rel="Chapter" href="Ftp_fs.html">
 
55
<link title="Netclient_tut" rel="Chapter" href="Netclient_tut.html">
 
56
<link title="Netgssapi" rel="Chapter" href="Netgssapi.html">
 
57
<link title="Nethttpd_types" rel="Chapter" href="Nethttpd_types.html">
 
58
<link title="Nethttpd_kernel" rel="Chapter" href="Nethttpd_kernel.html">
 
59
<link title="Nethttpd_reactor" rel="Chapter" href="Nethttpd_reactor.html">
 
60
<link title="Nethttpd_engine" rel="Chapter" href="Nethttpd_engine.html">
 
61
<link title="Nethttpd_services" rel="Chapter" href="Nethttpd_services.html">
 
62
<link title="Nethttpd_plex" rel="Chapter" href="Nethttpd_plex.html">
 
63
<link title="Nethttpd_util" rel="Chapter" href="Nethttpd_util.html">
 
64
<link title="Nethttpd_intro" rel="Chapter" href="Nethttpd_intro.html">
 
65
<link title="Netmech_scram" rel="Chapter" href="Netmech_scram.html">
 
66
<link title="Netmech_scram_gssapi" rel="Chapter" href="Netmech_scram_gssapi.html">
 
67
<link title="Netmcore" rel="Chapter" href="Netmcore.html">
 
68
<link title="Netmcore_camlbox" rel="Chapter" href="Netmcore_camlbox.html">
 
69
<link title="Netmcore_mempool" rel="Chapter" href="Netmcore_mempool.html">
 
70
<link title="Netmcore_heap" rel="Chapter" href="Netmcore_heap.html">
 
71
<link title="Netmcore_ref" rel="Chapter" href="Netmcore_ref.html">
 
72
<link title="Netmcore_array" rel="Chapter" href="Netmcore_array.html">
 
73
<link title="Netmcore_sem" rel="Chapter" href="Netmcore_sem.html">
 
74
<link title="Netmcore_mutex" rel="Chapter" href="Netmcore_mutex.html">
 
75
<link title="Netmcore_condition" rel="Chapter" href="Netmcore_condition.html">
 
76
<link title="Netmcore_queue" rel="Chapter" href="Netmcore_queue.html">
 
77
<link title="Netmcore_buffer" rel="Chapter" href="Netmcore_buffer.html">
 
78
<link title="Netmcore_matrix" rel="Chapter" href="Netmcore_matrix.html">
 
79
<link title="Netmcore_hashtbl" rel="Chapter" href="Netmcore_hashtbl.html">
 
80
<link title="Netmcore_process" rel="Chapter" href="Netmcore_process.html">
 
81
<link title="Netmcore_tut" rel="Chapter" href="Netmcore_tut.html">
 
82
<link title="Netplex_types" rel="Chapter" href="Netplex_types.html">
 
83
<link title="Netplex_mp" rel="Chapter" href="Netplex_mp.html">
 
84
<link title="Netplex_mt" rel="Chapter" href="Netplex_mt.html">
 
85
<link title="Netplex_log" rel="Chapter" href="Netplex_log.html">
 
86
<link title="Netplex_controller" rel="Chapter" href="Netplex_controller.html">
 
87
<link title="Netplex_container" rel="Chapter" href="Netplex_container.html">
 
88
<link title="Netplex_sockserv" rel="Chapter" href="Netplex_sockserv.html">
 
89
<link title="Netplex_workload" rel="Chapter" href="Netplex_workload.html">
 
90
<link title="Netplex_main" rel="Chapter" href="Netplex_main.html">
 
91
<link title="Netplex_config" rel="Chapter" href="Netplex_config.html">
 
92
<link title="Netplex_kit" rel="Chapter" href="Netplex_kit.html">
 
93
<link title="Rpc_netplex" rel="Chapter" href="Rpc_netplex.html">
 
94
<link title="Netplex_cenv" rel="Chapter" href="Netplex_cenv.html">
 
95
<link title="Netplex_semaphore" rel="Chapter" href="Netplex_semaphore.html">
 
96
<link title="Netplex_sharedvar" rel="Chapter" href="Netplex_sharedvar.html">
 
97
<link title="Netplex_mutex" rel="Chapter" href="Netplex_mutex.html">
 
98
<link title="Netplex_encap" rel="Chapter" href="Netplex_encap.html">
 
99
<link title="Netplex_intro" rel="Chapter" href="Netplex_intro.html">
 
100
<link title="Netplex_advanced" rel="Chapter" href="Netplex_advanced.html">
 
101
<link title="Netplex_admin" rel="Chapter" href="Netplex_admin.html">
 
102
<link title="Netshm" rel="Chapter" href="Netshm.html">
 
103
<link title="Netshm_data" rel="Chapter" href="Netshm_data.html">
 
104
<link title="Netshm_hashtbl" rel="Chapter" href="Netshm_hashtbl.html">
 
105
<link title="Netshm_array" rel="Chapter" href="Netshm_array.html">
 
106
<link title="Netshm_intro" rel="Chapter" href="Netshm_intro.html">
 
107
<link title="Netconversion" rel="Chapter" href="Netconversion.html">
 
108
<link title="Netchannels" rel="Chapter" href="Netchannels.html">
 
109
<link title="Netstream" rel="Chapter" href="Netstream.html">
 
110
<link title="Mimestring" rel="Chapter" href="Mimestring.html">
 
111
<link title="Netmime" rel="Chapter" href="Netmime.html">
 
112
<link title="Netsendmail" rel="Chapter" href="Netsendmail.html">
 
113
<link title="Neturl" rel="Chapter" href="Neturl.html">
 
114
<link title="Netaddress" rel="Chapter" href="Netaddress.html">
 
115
<link title="Netbuffer" rel="Chapter" href="Netbuffer.html">
 
116
<link title="Netdate" rel="Chapter" href="Netdate.html">
 
117
<link title="Netencoding" rel="Chapter" href="Netencoding.html">
 
118
<link title="Netulex" rel="Chapter" href="Netulex.html">
 
119
<link title="Netaccel" rel="Chapter" href="Netaccel.html">
 
120
<link title="Netaccel_link" rel="Chapter" href="Netaccel_link.html">
 
121
<link title="Nethtml" rel="Chapter" href="Nethtml.html">
 
122
<link title="Netstring_str" rel="Chapter" href="Netstring_str.html">
 
123
<link title="Netstring_pcre" rel="Chapter" href="Netstring_pcre.html">
 
124
<link title="Netmappings" rel="Chapter" href="Netmappings.html">
 
125
<link title="Netaux" rel="Chapter" href="Netaux.html">
 
126
<link title="Nethttp" rel="Chapter" href="Nethttp.html">
 
127
<link title="Netpagebuffer" rel="Chapter" href="Netpagebuffer.html">
 
128
<link title="Netfs" rel="Chapter" href="Netfs.html">
 
129
<link title="Netglob" rel="Chapter" href="Netglob.html">
 
130
<link title="Netauth" rel="Chapter" href="Netauth.html">
 
131
<link title="Netsockaddr" rel="Chapter" href="Netsockaddr.html">
 
132
<link title="Netnumber" rel="Chapter" href="Netnumber.html">
 
133
<link title="Rtypes" rel="Chapter" href="Rtypes.html">
 
134
<link title="Xdr_mstring" rel="Chapter" href="Xdr_mstring.html">
 
135
<link title="Xdr" rel="Chapter" href="Xdr.html">
 
136
<link title="Netcompression" rel="Chapter" href="Netcompression.html">
 
137
<link title="Netchannels_tut" rel="Chapter" href="Netchannels_tut.html">
 
138
<link title="Netmime_tut" rel="Chapter" href="Netmime_tut.html">
 
139
<link title="Netsendmail_tut" rel="Chapter" href="Netsendmail_tut.html">
 
140
<link title="Netulex_tut" rel="Chapter" href="Netulex_tut.html">
 
141
<link title="Neturl_tut" rel="Chapter" href="Neturl_tut.html">
 
142
<link title="Netsys" rel="Chapter" href="Netsys.html">
 
143
<link title="Netsys_posix" rel="Chapter" href="Netsys_posix.html">
 
144
<link title="Netsys_pollset" rel="Chapter" href="Netsys_pollset.html">
 
145
<link title="Netlog" rel="Chapter" href="Netlog.html">
 
146
<link title="Netexn" rel="Chapter" href="Netexn.html">
 
147
<link title="Netsys_win32" rel="Chapter" href="Netsys_win32.html">
 
148
<link title="Netsys_pollset_posix" rel="Chapter" href="Netsys_pollset_posix.html">
 
149
<link title="Netsys_pollset_win32" rel="Chapter" href="Netsys_pollset_win32.html">
 
150
<link title="Netsys_pollset_generic" rel="Chapter" href="Netsys_pollset_generic.html">
 
151
<link title="Netsys_signal" rel="Chapter" href="Netsys_signal.html">
 
152
<link title="Netsys_oothr" rel="Chapter" href="Netsys_oothr.html">
 
153
<link title="Netsys_xdr" rel="Chapter" href="Netsys_xdr.html">
 
154
<link title="Netsys_rng" rel="Chapter" href="Netsys_rng.html">
 
155
<link title="Netsys_types" rel="Chapter" href="Netsys_types.html">
 
156
<link title="Netsys_mem" rel="Chapter" href="Netsys_mem.html">
 
157
<link title="Netsys_tmp" rel="Chapter" href="Netsys_tmp.html">
 
158
<link title="Netgzip" rel="Chapter" href="Netgzip.html">
 
159
<link title="Netpop" rel="Chapter" href="Netpop.html">
 
160
<link title="Rpc_auth_dh" rel="Chapter" href="Rpc_auth_dh.html">
 
161
<link title="Rpc_key_service" rel="Chapter" href="Rpc_key_service.html">
 
162
<link title="Rpc_time" rel="Chapter" href="Rpc_time.html">
 
163
<link title="Rpc_auth_local" rel="Chapter" href="Rpc_auth_local.html">
 
164
<link title="Rpc_ssl" rel="Chapter" href="Rpc_ssl.html">
 
165
<link title="Rpc_xti_client" rel="Chapter" href="Rpc_xti_client.html">
 
166
<link title="Rpc" rel="Chapter" href="Rpc.html">
 
167
<link title="Rpc_program" rel="Chapter" href="Rpc_program.html">
 
168
<link title="Rpc_util" rel="Chapter" href="Rpc_util.html">
 
169
<link title="Rpc_portmapper_aux" rel="Chapter" href="Rpc_portmapper_aux.html">
 
170
<link title="Rpc_packer" rel="Chapter" href="Rpc_packer.html">
 
171
<link title="Rpc_transport" rel="Chapter" href="Rpc_transport.html">
 
172
<link title="Rpc_client" rel="Chapter" href="Rpc_client.html">
 
173
<link title="Rpc_simple_client" rel="Chapter" href="Rpc_simple_client.html">
 
174
<link title="Rpc_portmapper_clnt" rel="Chapter" href="Rpc_portmapper_clnt.html">
 
175
<link title="Rpc_portmapper" rel="Chapter" href="Rpc_portmapper.html">
 
176
<link title="Rpc_server" rel="Chapter" href="Rpc_server.html">
 
177
<link title="Rpc_auth_sys" rel="Chapter" href="Rpc_auth_sys.html">
 
178
<link title="Rpc_auth_gssapi" rel="Chapter" href="Rpc_auth_gssapi.html">
 
179
<link title="Rpc_proxy" rel="Chapter" href="Rpc_proxy.html">
 
180
<link title="Rpc_intro" rel="Chapter" href="Rpc_intro.html">
 
181
<link title="Rpc_mapping_ref" rel="Chapter" href="Rpc_mapping_ref.html">
 
182
<link title="Rpc_intro_gss" rel="Chapter" href="Rpc_intro_gss.html">
 
183
<link title="Shell_sys" rel="Chapter" href="Shell_sys.html">
 
184
<link title="Shell" rel="Chapter" href="Shell.html">
 
185
<link title="Shell_uq" rel="Chapter" href="Shell_uq.html">
 
186
<link title="Shell_fs" rel="Chapter" href="Shell_fs.html">
 
187
<link title="Shell_intro" rel="Chapter" href="Shell_intro.html">
 
188
<link title="Netsmtp" rel="Chapter" href="Netsmtp.html">
 
189
<link title="Intro" rel="Chapter" href="Intro.html">
 
190
<link title="Platform" rel="Chapter" href="Platform.html">
 
191
<link title="Foreword" rel="Chapter" href="Foreword.html">
 
192
<link title="Ipv6" rel="Chapter" href="Ipv6.html"><link title="Securing RPC with the GSS-API" rel="Section" href="#intro">
 
193
<link title="The GSS-API" rel="Subsection" href="#2_TheGSSAPI">
 
194
<link title="The GSS-API in Ocaml" rel="Subsection" href="#2_TheGSSAPIinOcaml">
 
195
<link title="SCRAM" rel="Subsection" href="#2_SCRAM">
 
196
<link title="Enabling SCRAM for RPC clients" rel="Subsection" href="#2_EnablingSCRAMforRPCclients">
 
197
<link title="Enabling SCRAM for RPC proxies" rel="Subsection" href="#2_EnablingSCRAMforRPCproxies">
 
198
<link title="Enabling SCRAM for RPC servers" rel="Subsection" href="#2_EnablingSCRAMforRPCservers">
 
199
<link title="Enabling SCRAM in Netplex context" rel="Subsection" href="#2_EnablingSCRAMinNetplexcontext">
 
200
<link title="Security considerations" rel="Subsection" href="#2_Securityconsiderations">
 
201
<title>Ocamlnet 3 Reference Manual : Rpc_intro_gss</title>
 
202
</head>
 
203
<body>
 
204
<div class="navbar"><a href="Rpc_mapping_ref.html">Previous</a>
 
205
&nbsp;<a href="index.html">Up</a>
 
206
&nbsp;<a href="Shell_sys.html">Next</a>
 
207
</div>
 
208
<center><h1>Rpc_intro_gss</h1></center>
 
209
<br>
 
210
<br>
 
211
<span id="intro"><h1>Securing RPC with the GSS-API</h1></span>
 
212
<p>
 
213
 
 
214
This text explains how to enable strong authentication and strong
 
215
encryption on RPC connections.
 
216
<p>
 
217
 
 
218
<span id="2_TheGSSAPI"><h2>The GSS-API</h2></span>
 
219
<p>
 
220
 
 
221
The GSS-API (Generic Security Service API) is an interface between
 
222
the security provider (i.e. the authentication/encryption provider)
 
223
and the application needing security features. The GSS-API is a
 
224
standard (RFC 2743). The GSS-API is often already implemented by
 
225
operating systems or by security systems like Kerberos. This means,
 
226
there is usually a library on the C level containing the C functions
 
227
defining GSS-API.
 
228
<p>
 
229
 
 
230
The nice thing about GSS-API is the mechanism genericy: The API can
 
231
provide access to multiple security mechanisms, and it is possible
 
232
to wrap almost every security mechanism in the form of GSS-API.
 
233
<p>
 
234
 
 
235
There is a "competitor" to GSS-API, namely SASL. The feature set is
 
236
not identical, though. Both APIs allow strong authentication.  GSS-API
 
237
additionally includes encryption and integrity protection for
 
238
message-oriented communication (but not for continuous data streams),
 
239
whereas SASL does not have such a feature and has to rely on external
 
240
layers to do so (which is often SSL). There is a bridge between GSS-API
 
241
and SASL called GS2 - it translates the authentication part of GSS-API
 
242
into SASL.
 
243
<p>
 
244
 
 
245
As mentioned, GSS-API only covers the encryption and integrity
 
246
protection of messages, not of continuous streams. In so far there is
 
247
not much intersection with SSL, which only handles such streams.  For
 
248
message-oriented protocols such as RPC the feature set of GSS-API is
 
249
naturally the better choice. There is a standard called RPCSEC-GSS
 
250
defining the details of how GSS-API is to be used for ONCRPC (RFC
 
251
2203).
 
252
<p>
 
253
 
 
254
<span id="2_TheGSSAPIinOcaml"><h2>The GSS-API in Ocaml</h2></span>
 
255
<p>
 
256
 
 
257
The GSS-API is defined as a class type <a href="Netgssapi.gss_api-c.html"><code class="code">Netgssapi.gss_api</code></a>. We do not
 
258
want to go much into detail - for <b>using</b> the GSS-API it is not
 
259
required to understand everything. The class type is "feature
 
260
compatible" with the standard C version of the API (RFC 2744)
 
261
allowing it to interface with implementations of GSS-API available
 
262
in C. (Note that this has not been done when this text is written.)
 
263
<p>
 
264
 
 
265
A class type has been chosen because this allows it that each
 
266
security provider can define an independent class implementing
 
267
the GSS-API. This is different than in the C bindings of GSS-API
 
268
where only one provider can exist at a time (linked into the program),
 
269
although the provider can manage several mechanisms.
 
270
<p>
 
271
 
 
272
When using GSS-API you will be confronted with OIDs, names, and
 
273
credentials. These concepts are defined in the <a href="Netgssapi.html"><code class="code">Netgssapi</code></a> module:
 
274
<p>
 
275
<ul>
 
276
<li>An OID (object identifier) is a IANA-registered number helping
 
277
  to identify especially security mechanisms, and styles of
 
278
  naming principals (user and system identities). OIDs are also
 
279
  used in other contexts (e.g. ASN-1, X500).</li>
 
280
<li>Names come in various forms, and because of this, GSS-API uses
 
281
  opaque objects for names, not strings. Names can e.g. identify
 
282
  users. There are various styles (name types). For example, users
 
283
  are often identified by a simple string ("guest") whereas
 
284
  service names also include the host name where the service runs
 
285
  ("emailserver@machine"). As names are opaque, they can be
 
286
  imported from a string representation to the opaque object
 
287
  and they can be converted back to strings.</li>
 
288
<li>Credentials are pieces of information allowing the security
 
289
  mechanism to check whether a connected participant has actually
 
290
  a certain name. A simple example is a password.</li>
 
291
</ul>
 
292
 
 
293
OIDs are represented as <code class="code">oid = int array</code>. There are a number of predefined
 
294
OIDs, e.g.
 
295
<p>
 
296
<ul>
 
297
<li><a href="Netgssapi.html#VALnt_user_name"><code class="code">Netgssapi.nt_user_name</code></a> is the OID of the name type identifying
 
298
  users by name</li>
 
299
<li><a href="Netgssapi.html#VALnt_hostbased_service"><code class="code">Netgssapi.nt_hostbased_service</code></a> is the OID of the name type
 
300
  identifying services relative to hosts</li>
 
301
<li><a href="Netmech_scram_gssapi.html#VALscram_mech"><code class="code">Netmech_scram_gssapi.scram_mech</code></a> is the OID of the SCRAM
 
302
  security mechanism</li>
 
303
</ul>
 
304
 
 
305
An empty array is often used to mean the default (e.g. default
 
306
mechanism).
 
307
<p>
 
308
 
 
309
Names are represented as <a href="Netgssapi.html#TYPEname"><code class="code">Netgssapi.name</code></a>. This object has almost
 
310
no methods - which is intended because names are opaque to users
 
311
outside the GSS-API implementation. The GSS-API defines methods
 
312
to import and export names:
 
313
<p>
 
314
<ul>
 
315
<li><a href="Netgssapi.gss_api-c.html#METHODimport_name"><code class="code">Netgssapi.gss_api.import_name</code></a> allows one to convert a pair
 
316
  of a name type and a string to the opaque <a href="Netgssapi.html#TYPEname"><code class="code">Netgssapi.name</code></a>
 
317
  object. The name type is an OID.</li>
 
318
<li><a href="Netgssapi.gss_api-c.html#METHODdisplay_name"><code class="code">Netgssapi.gss_api.display_name</code></a> is roughly the reverse operation
 
319
  (but see below).</li>
 
320
<li><a href="Netgssapi.gss_api-c.html#METHODexport_name"><code class="code">Netgssapi.gss_api.export_name</code></a> converts an opaque name to
 
321
  a binary string. It is ensured that another call of <code class="code">import_name</code>
 
322
  with the same string restores the opaque name.</li>
 
323
</ul>
 
324
 
 
325
Note that, at least for certain security mechanisms, there may be
 
326
several ways of writing the name of a principal, or there might be
 
327
naming elements spanning several mechanisms. This is an issue when
 
328
names need to be compared. Generally, it may lead to wrong results
 
329
when names are compared by displaying or exporting them, and then
 
330
comparing the resulting strings. There is a special
 
331
<a href="Netgssapi.gss_api-c.html#METHODcompare_name"><code class="code">Netgssapi.gss_api.compare_name</code></a> method for comparisons, and
 
332
<a href="Netgssapi.gss_api-c.html#METHODcanonicalize_name"><code class="code">Netgssapi.gss_api.canonicalize_name</code></a> may also be useful in this
 
333
context.
 
334
<p>
 
335
 
 
336
For RPC, the ways of referring to names have been simplified - more on
 
337
that below.
 
338
<p>
 
339
 
 
340
Credentials are also opaque objects - <a href="Netgssapi.html#TYPEcredential"><code class="code">Netgssapi.credential</code></a>. It is
 
341
generally assumed that a GSS-API implementation can look up the right
 
342
credentials for a principal that is identified by name. For example,
 
343
the GSS-API provider for SCRAM can be equipped with a "keyring", i.e.
 
344
a callback that maps user names to passwords.
 
345
<p>
 
346
 
 
347
<span id="2_SCRAM"><h2>SCRAM</h2></span>
 
348
<p>
 
349
 
 
350
SCRAM (Salted Challenge Response Authentication Mechanism) is a
 
351
relatively new security mechanism (RFC 5802) with interesting
 
352
properties:
 
353
<p>
 
354
<ul>
 
355
<li>It is a password-based authentication scheme</li>
 
356
<li>No complicated helpers like certification authorities or 
 
357
  ticket servers are required for deployment</li>
 
358
<li>The password is not transmitted during authentication (because
 
359
  of the challenge/response style)</li>
 
360
<li>The server needs not to store the password in cleartext. Only the salted
 
361
  password is needed, and it is not possible to use a salted password
 
362
  on the client (i.e. it is fruitless to steal the password database)</li>
 
363
<li>Not only the client authenticates to the server, but also vice
 
364
  versa - the protocol proves to the client that the server has access
 
365
  to the salted password</li>
 
366
<li>The server does not have a name</li>
 
367
</ul>
 
368
 
 
369
There is an extension for SCRAM so that AES-128 encryption and 
 
370
SHA-1 integrity protection become available in GSS-API context.
 
371
<p>
 
372
 
 
373
SCRAM is implemented in <a href="Netmech_scram.html"><code class="code">Netmech_scram</code></a>. The GSS-API encapsulation
 
374
is done in <a href="Netmech_scram_gssapi.html"><code class="code">Netmech_scram_gssapi</code></a>.
 
375
<p>
 
376
 
 
377
Some more words on names and credentials: Clients have to impersonate
 
378
as a user, given by a simple unstructured string. The RFC requires
 
379
that this string is UTF-8, and that certain Unicode normalizations
 
380
need to be applied before use. This is not implemented right now
 
381
(SASLprep is missing). Because of this, only US-ASCII user names are
 
382
accepted. The same applies to the passwords.
 
383
<p>
 
384
 
 
385
In SCRAM, the client needs to know the password in cleartext. The
 
386
server, however, usually only stores a triple
 
387
<p>
 
388
 
 
389
<pre><code class="code"> (salted_password, salt, iteration_count) </code></pre>
 
390
<p>
 
391
 
 
392
in the authentication database. The <code class="code">iteration_count</code> is a
 
393
constant defined by the server (should be &gt;= 4096). The <code class="code">salt</code> is
 
394
a random string that is created when the user entry is added to the
 
395
database. The function <a href="Netmech_scram.html#VALcreate_salt"><code class="code">Netmech_scram.create_salt</code></a> can be used
 
396
for this. The <code class="code">salted_password</code> can be computed from the two other
 
397
parameters and the password with <a href="Netmech_scram.html#VALsalt_password"><code class="code">Netmech_scram.salt_password</code></a>.
 
398
<p>
 
399
 
 
400
The GSS-API encapsulation of SCRAM is <a href="Netmech_scram_gssapi.scram_gss_api-c.html"><code class="code">Netmech_scram_gssapi.scram_gss_api</code></a>.
 
401
This class
 
402
<p>
 
403
 
 
404
<pre><code class="code">class scram_gss_api : 
 
405
        ?client_key_ring:client_key_ring -&gt;
 
406
        ?server_key_verifier:server_key_verifier -&gt;
 
407
        Netmech_scram.profile -&gt;
 
408
          Netgssapi.gss_api
 
409
</code></pre>
 
410
<p>
 
411
 
 
412
takes a few arguments. The <code class="code">profile</code> can be just obtained by calling
 
413
<p>
 
414
 
 
415
<pre><code class="code">Netmech_scram.profile `GSSAPI
 
416
</code></pre>
 
417
<p>
 
418
 
 
419
which is usally the right thing here (one can also set a few parameters
 
420
at this point). Depending on whether the class is needed for clients
 
421
or servers, one passes either <code class="code">client_key_ring</code> or <code class="code">server_key_verifier</code>.
 
422
<p>
 
423
 
 
424
<a href="Netmech_scram_gssapi.client_key_ring-c.html"><code class="code">Netmech_scram_gssapi.client_key_ring</code></a> is an object like
 
425
<p>
 
426
 
 
427
<pre><code class="code">let client_key_ring =
 
428
  object
 
429
    method password_of_user_name user =
 
430
      match user with
 
431
       | "guest" -&gt; "guest"
 
432
       | "gerd" -&gt; "I won't reveal it"
 
433
       | _ -&gt; raise Not_found
 
434
 
 
435
    method default_user_name = Some "guest"
 
436
  end
 
437
</code></pre>
 
438
<p>
 
439
 
 
440
that mainly returns the passwords of users and that optionally defines
 
441
a default user. (E.g. the default user could be set to the current
 
442
login name of the process running the client.)
 
443
<p>
 
444
 
 
445
<a href="Netmech_scram_gssapi.server_key_verifier-c.html"><code class="code">Netmech_scram_gssapi.server_key_verifier</code></a> provides the credentials
 
446
for password verification, e.g.
 
447
<p>
 
448
 
 
449
<pre><code class="code">let server_key_verifier =
 
450
  object
 
451
    method scram_credentials user =
 
452
      match user with
 
453
       | "guest" -&gt;
 
454
            ("\209\002U?,/Vu\253&amp;\140\196j\158{b]\221\140\029", 
 
455
             "68bd268fe5e948a7e171a4df9ef6450a", 
 
456
             4096)
 
457
       | "gerd" -&gt;
 
458
            ("\135\202\182P\142\r\175?\222\156\201bA\188\1296\154\197v\142",
 
459
             "5e51d100ace8d1a69cd4d015ac5da947", 
 
460
             4096)
 
461
       | _ -&gt; raise Not_found
 
462
  end
 
463
</code></pre>
 
464
<p>
 
465
 
 
466
<span id="2_EnablingSCRAMforRPCclients"><h2>Enabling SCRAM for RPC clients</h2></span>
 
467
<p>
 
468
 
 
469
Basically, an RPC client is created by a call like
 
470
<p>
 
471
 
 
472
<pre><code class="code">let client = Rpc_client.create2 m prog esys
 
473
</code></pre>
 
474
<p>
 
475
 
 
476
or by invoking ocamlrpcgen-created wrappers of this call. How can we
 
477
enable SCRAM authentication?
 
478
<p>
 
479
 
 
480
Assumed we already created the <code class="code">gss_api</code> object by instantiating the
 
481
class <a href="Netmech_scram_gssapi.scram_gss_api-c.html"><code class="code">Netmech_scram_gssapi.scram_gss_api</code></a> this is done in two steps:
 
482
<p>
 
483
<ul>
 
484
<li>Create the authentication method on RPC level:
 
485
  <pre><code class="code"> 
 
486
  let am = 
 
487
    Rpc_auth_gssapi.client_auth_method
 
488
      ~user_name_interpretation:(`Plain_name Netgssapi.nt_user_name)
 
489
      gss_api Netmech_scram.scram_mech
 
490
  </code></pre></li>
 
491
<li>Add this method to the client:
 
492
  <pre><code class="code">  Rpc_client.set_auth_methods client [am]
 
493
  </code></pre></li>
 
494
</ul>
 
495
 
 
496
Optionally, one can also do a third step:
 
497
<p>
 
498
<ul>
 
499
<li>Set the user (if you do not want to impersonate the default user):
 
500
  <pre><code class="code">  Rpc_client.set_user_name client (Some "gerd")
 
501
  </code></pre></li>
 
502
</ul>
 
503
 
 
504
That's it!
 
505
<p>
 
506
 
 
507
Of course, <code class="code">am</code> can be shared by several clients. This does not mean,
 
508
however, that the clients share the security contexts. For each client
 
509
a separate context is created (i.e. the authentication protocol starts
 
510
from the beginning).
 
511
<p>
 
512
 
 
513
Both TCP and UDP are supported. Note that especially for UDP there
 
514
might be issues with retransmitted client requests after running into
 
515
timeouts. The problem is that retransmitted requests and the following
 
516
responses look different on the wire than the original messages, and
 
517
because of this the client can only accept a response when it is the
 
518
response to the latest retransmission. This makes the retransmission
 
519
feature less reliable. Best is to avoid UDP.
 
520
<p>
 
521
 
 
522
The function <a href="Rpc_auth_gssapi.html#VALclient_auth_method"><code class="code">Rpc_auth_gssapi.client_auth_method</code></a> has a few optional
 
523
arguments controlling whether encryption or integrity protection are
 
524
enabled:
 
525
<p>
 
526
<ul>
 
527
<li>By setting <code class="code">~privacy:`Required</code> it is ensured that encryption and
 
528
  integrity protection are both enabled. If the security mechanism
 
529
  does not provide this, the function fails.</li>
 
530
<li>The default is <code class="code">~privacy:`If_possible</code>. This means that
 
531
  privacy is enabled if the mechanism supports it.</li>
 
532
<li>There is a second argument <code class="code">~integrity</code> only controlling integrity
 
533
  protection. It comes into play if full privacy is not available
 
534
  or if it is disabled with <code class="code">~privacy:`None</code>. If integrity protection
 
535
  is on but full privacy is off the messages are not encrypted but
 
536
  only signed with a checksum.</li>
 
537
<li>One can also turn both features off: <code class="code">~privacy:`None</code> and <code class="code">~integrity:`None</code>.
 
538
  In this case, the messages are neither enrypted nor protected. 
 
539
  The authentication protocol at the beginning of a session is unaffected
 
540
  and is done nevertheless. This may be an option if you only want
 
541
  to authenticate a TCP connection but not protect the connection.
 
542
  For UDP it is strongly discouraged to use this mode - it is very
 
543
  easy to hack this.</li>
 
544
<li>Of course, the RPC server has the last word which protection level is
 
545
  acceptable.</li>
 
546
</ul>
 
547
 
 
548
You might have wondered why we pass
 
549
<p>
 
550
 
 
551
<pre><code class="code">~user_name_interpretation:(`Plain_name Netgssapi.nt_user_name)
 
552
</code></pre>
 
553
<p>
 
554
 
 
555
to <code class="code">client_auth_method</code>. As described above, there are various ways
 
556
how to represent names. In the RPC context we need a simple string.
 
557
The <code class="code">user_name_interpretation</code> argument selects how the opaque
 
558
GSS-API names are converted to strings.
 
559
<p>
 
560
 
 
561
<span id="2_EnablingSCRAMforRPCproxies"><h2>Enabling SCRAM for RPC proxies</h2></span>
 
562
<p>
 
563
 
 
564
The <a href="Rpc_proxy.html"><code class="code">Rpc_proxy</code></a> module is a higher-level encapsulation of RPC clients
 
565
providing additional reliability features. One can also configure the
 
566
proxies to use authentication:
 
567
<p>
 
568
<ul>
 
569
<li>Pass the authentication method <code class="code">am</code> (as created above) in the
 
570
  mclient config with the argument <code class="code">~auth_methods</code>, see
 
571
  <a href="Rpc_proxy.ManagedClient.html#VALcreate_mclient_config"><code class="code">Rpc_proxy.ManagedClient.create_mclient_config</code></a>.</li>
 
572
<li>Set the user in the mclient config with the argument <code class="code">~user_name</code></li>
 
573
</ul>
 
574
 
 
575
This could e.g. look like
 
576
<p>
 
577
 
 
578
<pre><code class="code">let config =
 
579
  Rpc_proxy.ManagedClient.create_mclient_config
 
580
    ...
 
581
    ~auth_methods:[am]
 
582
    ~user_name:(Some "gerd")
 
583
    ...
 
584
    ()
 
585
</code></pre>
 
586
<p>
 
587
 
 
588
The <code class="code">config</code> value can then, as usual, be passed to
 
589
<a href="Rpc_proxy.ManagedClient.html#VALcreate_mclient"><code class="code">Rpc_proxy.ManagedClient.create_mclient</code></a>.
 
590
<p>
 
591
 
 
592
<span id="2_EnablingSCRAMforRPCservers"><h2>Enabling SCRAM for RPC servers</h2></span>
 
593
<p>
 
594
 
 
595
The general procedure for enabling authentication is similar to that
 
596
in client context:
 
597
<p>
 
598
<ul>
 
599
<li>Create the authentication method on RPC level:
 
600
  <pre><code class="code"> 
 
601
  let am = 
 
602
    Rpc_auth_gssapi.server_auth_method
 
603
      ~user_name_format:`Plain_name
 
604
      gss_api Netmech_scram.scram_mech
 
605
  </code></pre></li>
 
606
<li>Add this method to the server:
 
607
  <pre><code class="code">  Rpc_server.set_auth_methods server [am]
 
608
  </code></pre></li>
 
609
</ul>
 
610
 
 
611
The method <code class="code">am</code> can be shared by several servers.
 
612
<p>
 
613
 
 
614
Each connection to a server normally opens a new security context (or
 
615
better, the context handles are kept private per connection).  There
 
616
is a special mode, however, permitting a more liberal setting: By
 
617
passing <code class="code">~shared_context:true</code> to
 
618
<a href="Rpc_auth_gssapi.html#VALserver_auth_method"><code class="code">Rpc_auth_gssapi.server_auth_method</code></a> independent connections can
 
619
share security contexts if they know the security handles. Although
 
620
the Ocamlnet client does not support this mode, it might be required
 
621
for interoperability with other implementations. Also, for UDP
 
622
servers this mode <b>must</b> be enabled - each UDP request/response
 
623
pair is considered as a new connection by the RPC server (in some
 
624
sense this is a peculiarity of the implementation).
 
625
<p>
 
626
 
 
627
You can get the name of the authenticated user with the function
 
628
<a href="Rpc_server.html#VALget_user"><code class="code">Rpc_server.get_user</code></a>. The way of translating opaque GSS-API names
 
629
to strings can be selected with the <code class="code">~user_name_format</code> argument
 
630
of <a href="Rpc_auth_gssapi.html#VALserver_auth_method"><code class="code">Rpc_auth_gssapi.server_auth_method</code></a>.
 
631
<p>
 
632
 
 
633
By setting <code class="code">~require_privacy</code> one can demand that only privacy-protected
 
634
messages are accepted. <code class="code">~require_integrity</code> demands that at least
 
635
integrity-protected messages are used.
 
636
<p>
 
637
 
 
638
<span id="2_EnablingSCRAMinNetplexcontext"><h2>Enabling SCRAM in Netplex context</h2></span>
 
639
<p>
 
640
 
 
641
The question is where to call <a href="Rpc_server.html#VALset_auth_methods"><code class="code">Rpc_server.set_auth_methods</code></a>.
 
642
<p>
 
643
 
 
644
RPC services are created by using <a href="Rpc_netplex.html#VALrpc_factory"><code class="code">Rpc_netplex.rpc_factory</code></a>. This
 
645
function has an argument <code class="code">setup</code> which is a callback for configuring
 
646
the server.  Usually, this callback is used to bind the RPC procedure
 
647
functions to the server object. This is also the ideal place to
 
648
set the authentication method.
 
649
<p>
 
650
 
 
651
<b>Pitfall:</b> Note that <code class="code">setup</code> may also be called for dummy servers
 
652
that are not connected to real file descriptors. Netplex does this
 
653
to find out how the server will be configured (especially it is
 
654
interested in the list of procedures). If this is an issue you can
 
655
test for a dummy server with <a href="Rpc_server.html#VALis_dummy"><code class="code">Rpc_server.is_dummy</code></a>.
 
656
<p>
 
657
 
 
658
<span id="2_Securityconsiderations"><h2>Security considerations</h2></span>
 
659
<p>
 
660
 
 
661
SCRAM seems to be an excellent choice for a password-based
 
662
authentication protocol. Of course, it has all the well-known
 
663
weaknesses of the password approach (e.g. dictionary attacks are
 
664
possible), but otherwise it is certainly state of the art.
 
665
<p>
 
666
 
 
667
The RPC messages are encrypted with AES-128. This is not configurable.
 
668
<p>
 
669
 
 
670
Integrity protection is obtained by using SHA-1 hashes. This is also
 
671
not configurable.
 
672
<p>
 
673
 
 
674
Some parts of the RPC messages are not fully protected: Headers and
 
675
error responses. This means that the numbers identifying the called
 
676
RPC procedures are not privacy-protected. They are only
 
677
integrity-protected.
 
678
<p>
 
679
 
 
680
Error responses are completely unprotected.
 
681
<p>
 
682
 
 
683
<br>
 
684
</body></html>
 
 
b'\\ No newline at end of file'