forked from KOBA789/node.js_ja
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhttps.html
More file actions
487 lines (415 loc) · 19.3 KB
/
Copy pathhttps.html
File metadata and controls
487 lines (415 loc) · 19.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>HTTPS Node.js v0.11.11 Manual & Documentation</title>
<link rel="stylesheet" href="assets/style.css">
<link rel="stylesheet" href="assets/sh.css">
<link rel="canonical" href="http://nodejs.org/api/https.html">
</head>
<body class="alt apidoc" id="api-section-https">
<div id="intro" class="interior">
<a href="/" title="Go back to the home page">
<img id="logo" src="http://nodejs.org/images/logo-light.png" alt="node.js">
</a>
</div>
<div id="content" class="clearfix">
<div id="column2" class="interior">
<ul>
<!--
<li><a href="/" class="home">Home</a></li>
<li><a href="/download/" class="download">Download</a></li>
<li><a href="/about/" class="about">About</a></li>
<li><a href="http://npmjs.org/" class="npm">npm Registry</a></li>
<li><a href="http://nodejs.org/api/" class="docs current">Docs</a></li>
<li><a href="http://blog.nodejs.org" class="blog">Blog</a></li>
<li><a href="/community/" class="community">Community</a></li>
<li><a href="/logos/" class="logos">Logos</a></li>
-->
<li><a href="../" class="home">ホーム</a></li>
<li><a href="../#download" class="download">ダウンロード</a></li>
<li><a href="../about/" class="about">概要</a></li>
<li><a href="http://npmjs.org/" class="npm">npm レジストリ</a></li>
<li><a href="../api/" class="docs current">ドキュメント</a></li>
<li><a href="http://blog.nodejs.org" class="blog">ブログ</a></li>
<li><a href="../community/" class="community">コミュニティ</a></li>
<li><a href="../logos/" class="logos">ロゴ</a></li>
<li><a href="http://jobs.nodejs.org/" class="jobs">Jobs</a></li>
</ul>
<p class="twitter"><a href="http://twitter.com/nodejs">@nodejs</a></p>
</div>
<div id="column1" class="interior">
<header>
<h1>Node.js v0.11.11 マニュアル & ドキュメンテーション</h1>
<div id="gtoc">
<p>
<a href="index.html" name="toc">Index</a> |
<a href="all.html">View on single page</a> |
<a href="https.json">View as JSON</a>
</p>
</div>
<hr>
</header>
<div id="toc">
<h2>Table of Contents</h2>
<ul>
<li><a href="#https_https">HTTPS</a><ul>
<li><a href="#https_class_https_server">Class: https.Server</a><ul>
<li><a href="#https_server_settimeout_msecs_callback">server.setTimeout(msecs, callback)</a></li>
<li><a href="#https_server_timeout">server.timeout</a></li>
<li><a href="#https_server_listen_port_host_backlog_callback">server.listen(port, [host], [backlog], [callback])</a></li>
<li><a href="#https_server_listen_path_callback">server.listen(path, [callback])</a></li>
<li><a href="#https_server_listen_handle_callback">server.listen(handle, [callback])</a></li>
<li><a href="#https_server_close_callback">server.close([callback])</a></li>
</ul>
</li>
<li><a href="#https_https_request_options_callback">https.request(options, callback)</a></li>
<li><a href="#https_https_get_options_callback">https.get(options, callback)</a></li>
<li><a href="#https_class_https_agent">Class: https.Agent</a></li>
<li><a href="#https_https_globalagent">https.globalAgent</a></li>
</ul>
</li>
</ul>
</div>
<div id="apicontent">
<h1>HTTPS<span><a class="mark" href="#https_https" id="https_https">#</a></span></h1>
<pre class="api_stability_3">Stability: 3 - Stable</pre><!--
HTTPS is the HTTP protocol over TLS/SSL. In Node this is implemented as a
separate module.
-->
<p>HTTPS は TLS/SSL 上の HTTP プロトコルです。
Node ではこれらは別のモジュールとして実装されています。
</p>
<h2>Class: https.Server<span><a class="mark" href="#https_class_https_server" id="https_class_https_server">#</a></span></h2>
<!--
This class is a subclass of `tls.Server` and emits events same as
`http.Server`. See `http.Server` for more information.
-->
<p>このクラスは <code>tls.Server</code> のサブクラスで、<code>http.Server</code> と同様のイベントを生成します。
より詳しくは <code>http.Server</code> を参照してください。
</p>
<h3>server.setTimeout(msecs, callback)<span><a class="mark" href="#https_server_settimeout_msecs_callback" id="https_server_settimeout_msecs_callback">#</a></span></h3>
<!--
See [http.Server#setTimeout()][].
-->
<p><a href="http.html#http_server_settimeout_msecs_callback">http.Server#setTimeout()</a> を参照してください。
</p>
<h3>server.timeout<span><a class="mark" href="#https_server_timeout" id="https_server_timeout">#</a></span></h3>
<!--
See [http.Server#timeout][].
[http.Server#timeout][] を参照してください。
## https.createServer(options, [requestListener])
<!--
Returns a new HTTPS web server object. The `options` is similar to
[tls.createServer()][]. The `requestListener` is a function which is
automatically added to the `'request'` event.
-->
<p>新しい HTTPS Web サーバオブジェクトを返します。
<code>option</code> は <a href="tls.html#tls_tls_createserver_options_secureconnectionlistener">tls.createServer()</a> と同じです。
<code>requestListener</code> は関数で、 <code>'request'</code> イベントに自動的に追加されます。
</p>
<!--
Example:
-->
<p>例:
</p>
<pre><code>// curl -k https://localhost:8000/
var https = require('https');
var fs = require('fs');
var options = {
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};
https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(8000);</code></pre>
<!--
Or
-->
<p>または:
</p>
<pre><code>var https = require('https');
var fs = require('fs');
var options = {
pfx: fs.readFileSync('server.pfx')
};
https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(8000);</code></pre>
<h3>server.listen(port, [host], [backlog], [callback])<span><a class="mark" href="#https_server_listen_port_host_backlog_callback" id="https_server_listen_port_host_backlog_callback">#</a></span></h3>
<h3>server.listen(path, [callback])<span><a class="mark" href="#https_server_listen_path_callback" id="https_server_listen_path_callback">#</a></span></h3>
<h3>server.listen(handle, [callback])<span><a class="mark" href="#https_server_listen_handle_callback" id="https_server_listen_handle_callback">#</a></span></h3>
<!--
See [http.listen()][] for details.
-->
<p>詳細は <a href="http.html#http_server_listen_port_hostname_backlog_callback">http.listen()</a> を参照してください。
</p>
<h3>server.close([callback])<span><a class="mark" href="#https_server_close_callback" id="https_server_close_callback">#</a></span></h3>
<p>See <a href="http.html#http_server_close_callback">http.close()</a> for details.
</p>
<p>詳細は <a href="http.html#http_server_close_callback">http.close()</a> を参照してください。
</p>
<h2>https.request(options, callback)<span><a class="mark" href="#https_https_request_options_callback" id="https_https_request_options_callback">#</a></span></h2>
<!--
Makes a request to a secure web server.
-->
<p>セキュアな Web サーバへのリクエストを作成します。
</p>
<!--
`options` can be an object or a string. If `options` is a string, it is
automatically parsed with [url.parse()](url.html#url.parse).
-->
<p><code>options</code> はオブジェクトまたは文字列です。
<code>options</code> が文字列なら、それは自動的に <a href="url.html#url.parse">url.parse()</a>
によって解析されます。
</p>
<!--
All options from [http.request()][] are valid.
-->
<p><a href="http.html#http_http_request_options_callback">http.request()</a> の全てと同様のオプションが指定できます。
</p>
<!--
Example:
-->
<p>例:
</p>
<pre><code>var https = require('https');
var options = {
hostname: 'encrypted.google.com',
port: 443,
path: '/',
method: 'GET'
};
var req = https.request(options, function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
});
});
req.end();
req.on('error', function(e) {
console.error(e);
});</code></pre>
<!--
The options argument has the following options
-->
<p><code>options</code> 引数は以下のオプションを持ちます。
</p>
<!--
- `host`: A domain name or IP address of the server to issue the request to.
Defaults to `'localhost'`.
- `hostname`: To support `url.parse()` `hostname` is preferred over `host`
- `port`: Port of remote server. Defaults to 443.
- `method`: A string specifying the HTTP request method. Defaults to `'GET'`.
- `path`: Request path. Defaults to `'/'`. Should include query string if any.
E.G. `'/index.html?page=12'`
- `headers`: An object containing request headers.
- `auth`: Basic authentication i.e. `'user:password'` to compute an
Authorization header.
- `agent`: Controls [Agent][] behavior. When an Agent is used request will
default to `Connection: keep-alive`. Possible values:
- `undefined` (default): use [globalAgent][] for this host and port.
- `Agent` object: explicitly use the passed in `Agent`.
- `false`: opts out of connection pooling with an Agent, defaults request to
`Connection: close`.
-->
<ul>
<li><code>host</code>: リクエストを発行するサーバのドメイン名または IP アドレス。</li>
<li><code>hostname</code>: <code>url.parse()</code> で扱える文字列をサポートします。
<code>hostname</code> は <code>host</code> を上書きします。</li>
<li><code>port</code>: リモートサーバのポート。デフォルトは 443 です。</li>
<li><code>method</code>: HTTPS リクエストのメソッドの文字列。デフォルトは <code>'GET'</code> です。</li>
<li><code>path</code>: リクエストのパス。デフォルトは <code>'/'</code> です。
必要なら問い合わせ文字列を含めるべきです.
例 <code>'/index.html?page=12'</code></li>
<li><code>headers</code>: リクエストヘッダを含むオブジェクト。</li>
<li><code>auth</code>: べーしく認証すなわち Authorization ヘッダのための <code>'user:password'</code>。</li>
<li><code>agent</code>: <a href="#https_class_https_agent">Agent</a> の振る舞いを制御します。
エージェントが使われる場合、<code>Connection:keep-alive</code> がデフォルトになります。
可能な値は:<ul>
<li><code>undefined</code> (デフォルト): ホストとポートで <a href="#https_https_globalagent">globalAgent</a> を使用します。</li>
<li><code>Agent</code> オブジェクト: 明示的に渡された <code>Agent</code> を使用します。</li>
<li><code>false</code>: Agent によるコネクションプーリングを使用しません。
<code>Connection:close</code> の場合のデフォルトです。</li>
</ul>
</li>
</ul>
<!--
The following options from [tls.connect()][] can also be specified. However, a
[globalAgent][] silently ignores these.
-->
<p>以下の <a href="tls.html#tls_tls_connect_options_callback">tls.connect()</a> 由来のオプションを指定することもできますが、
グローバル <a href="#https_https_globalagent">globalAgent</a> はこれらを無視します。
</p>
<!--
- `pfx`: Certificate, Private key and CA certificates to use for SSL. Default `null`.
- `key`: Private key to use for SSL. Default `null`.
- `passphrase`: A string of passphrase for the private key or pfx. Default `null`.
- `cert`: Public x509 certificate to use. Default `null`.
- `ca`: An authority certificate or array of authority certificates to check
the remote host against.
- `ciphers`: A string describing the ciphers to use or exclude. Consult
<http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT> for
details on the format.
- `rejectUnauthorized`: If `true`, the server certificate is verified against
the list of supplied CAs. An `'error'` event is emitted if verification
fails. Verification happens at the connection level, *before* the HTTP
request is sent. Default `true`.
- `secureProtocol`: The SSL method to use, e.g. `SSLv3_method` to force
SSL version 3. The possible values depend on your installation of
OpenSSL and are defined in the constant [SSL_METHODS][].
-->
<ul>
<li><code>pfx</code>: SSL で使用する証明書、秘密鍵、認証局の証明書。
デフォルトは <code>null</code> です。</li>
<li><code>key</code>: SSL で使用する秘密鍵。デフォルトは <code>null</code> です。</li>
<li><code>passphrase</code>: 秘密鍵または pfx のパスフレーズを表す文字列。
デフォルトは <code>null</code> です。</li>
<li><code>cert</code>: x509公開証明書。デフォルトは <code>null</code> です。</li>
<li><code>ca</code>: リモートホストをチェックする信頼できる認証局または認証局の配列。</li>
<li><code>ciphers</code>: 使用または除外する暗号を記述した文字列。
詳細は <a href="http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT">http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT</a>
を参照してください。</li>
<li><code>rejectUnauthorized</code>: <code>true</code> の場合、サーバ証明書は提供された認証局の
リストによって検証されます。
認証されなかった場合は <code>'error'</code> イベントが生成されます。
認証は HTTP リクエストが送信される <em>前</em> にコネクションレベルで行われます。
デフォルトは <code>true</code> です。</li>
<li><code>secureProtocol</code>: 使用する SSL メソッド、たとえば <code>SSLv3_method</code> は
SSL version 3 の使用を強制します。可能な値は使用する OpenSSL によって
定義される <a href="http://www.openssl.org/docs/ssl/ssl.html#DEALING_WITH_PROTOCOL_METHODS">SSL_METHODS</a> 定数に依存します。</li>
</ul>
<!--
In order to specify these options, use a custom `Agent`.
-->
<p>これらのオプションを指定するには、カスタムエージェントを使用します。
</p>
<!--
Example:
-->
<p>例:
</p>
<pre><code>var options = {
hostname: 'encrypted.google.com',
port: 443,
path: '/',
method: 'GET',
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};
options.agent = new https.Agent(options);
var req = https.request(options, function(res) {
...
}</code></pre>
<!--
Or does not use an `Agent`.
-->
<p>あるいは、エージェントを使用しません。
</p>
<!--
Example:
-->
<p>例:
</p>
<pre><code>var options = {
hostname: 'encrypted.google.com',
port: 443,
path: '/',
method: 'GET',
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
agent: false
};
var req = https.request(options, function(res) {
...
}</code></pre>
<h2>https.get(options, callback)<span><a class="mark" href="#https_https_get_options_callback" id="https_https_get_options_callback">#</a></span></h2>
<!--
Like `http.get()` but for HTTPS.
-->
<p><code>http.get()</code> と同様ですが HTTPS です。
</p>
<!--
`options` can be an object or a string. If `options` is a string, it is
automatically parsed with [url.parse()](url.html#url.parse).
-->
<p><code>options</code> はオブジェクトまたは文字列です。
<code>options</code> が文字列なら、それは自動的に <a href="url.html#url.parse">url.parse()</a>
によって解析されます。
</p>
<!--
Example:
-->
<p>例:
</p>
<pre><code>var https = require('https');
https.get('https://encrypted.google.com/', function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
});
}).on('error', function(e) {
console.error(e);
});</code></pre>
<h2>Class: https.Agent<span><a class="mark" href="#https_class_https_agent" id="https_class_https_agent">#</a></span></h2>
<!--
An Agent object for HTTPS similar to [http.Agent][]. See [https.request()][]
for more information.
-->
<p>HTTPS 用の Agent オブジェクトで,<a href="http.html#http_class_http_agent">http.Agent</a> と同様です。
詳細は <a href="#https_https_request_options_callback">https.request()</a> を参照してください。
</p>
<h2>https.globalAgent<span><a class="mark" href="#https_https_globalagent" id="https_https_globalagent">#</a></span></h2>
<!--
Global instance of [https.Agent][] for all HTTPS client requests.
-->
<p>全ての HTTPS クライアントリクエストで使用される、デフォルトの
<a href="#https_class_https_agent">https.Agent</a> のインスタンスです。
</p>
</div>
</div>
</div>
<div id="footer">
<a href="http://joyent.com" class="joyent-logo">Joyent</a>
<ul class="clearfix">
<!--
<li><a href="/">Node.js</a></li>
<li><a href="/download/">Download</a></li>
<li><a href="/about/">About</a></li>
<li><a href="http://npmjs.org/">npm Registry</a></li>
<li><a href="http://nodejs.org/api/">Docs</a></li>
<li><a href="http://blog.nodejs.org">Blog</a></li>
<li><a href="/community/">Community</a></li>
<li><a href="/logos/">Logos</a></li>
-->
<li><a href="../">Node.js</a></li>
<li><a href="../#download">ダウンロード</a></li>
<li><a href="../about/">概要</a></li>
<li><a href="http://npmjs.org/">npm レジストリ</a></li>
<li><a href="../api/">ドキュメント</a></li>
<li><a href="http://blog.nodejs.org">ブログ</a></li>
<li><a href="../community/">コミュニティ</a></li>
<li><a href="../logos/">ロゴ</a></li>
<li><a href="http://jobs.nodejs.org/">Jobs</a></li>
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
</ul>
<p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/v0.11.11/LICENSE">license</a>.</p>
</div>
<script src="../sh_main.js"></script>
<script src="../sh_javascript.min.js"></script>
<script>highlight(undefined, undefined, 'pre');</script>
<script>
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
(function(d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
g.src = '//www.google-analytics.com/ga.js';
s.parentNode.insertBefore(g, s);
}(document, 'script'));
</script>
</body>
</html>