index.apt.vm 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. ~~ Licensed under the Apache License, Version 2.0 (the "License");
  2. ~~ you may not use this file except in compliance with the License.
  3. ~~ You may obtain a copy of the License at
  4. ~~
  5. ~~ http://www.apache.org/licenses/LICENSE-2.0
  6. ~~
  7. ~~ Unless required by applicable law or agreed to in writing, software
  8. ~~ distributed under the License is distributed on an "AS IS" BASIS,
  9. ~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. ~~ See the License for the specific language governing permissions and
  11. ~~ limitations under the License.
  12. ---
  13. Hadoop KMS - Documentation Sets ${project.version}
  14. ---
  15. ---
  16. ${maven.build.timestamp}
  17. Hadoop Key Management Server (KMS) - Documentation Sets ${project.version}
  18. Hadoop KMS is a cryptographic key management server based on Hadoop's
  19. <<KeyProvider>> API.
  20. It provides a client and a server components which communicate over
  21. HTTP using a REST API.
  22. The client is a KeyProvider implementation interacts with the KMS
  23. using the KMS HTTP REST API.
  24. KMS and its client have built-in security and they support HTTP SPNEGO
  25. Kerberos authentication and HTTPS secure transport.
  26. KMS is a Java web-application and it runs using a pre-configured Tomcat
  27. bundled with the Hadoop distribution.
  28. * KMS Client Configuration
  29. The KMS client <<<KeyProvider>>> uses the <<kms>> scheme, and the embedded
  30. URL must be the URL of the KMS. For example, for a KMS running
  31. on <<<http://localhost:16000/kms>>>, the KeyProvider URI is
  32. <<<kms://http@localhost:16000/kms>>>. And, for a KMS running on
  33. <<<https://localhost:16000/kms>>>, the KeyProvider URI is
  34. <<<kms://https@localhost:16000/kms>>>
  35. * KMS
  36. ** KMS Configuration
  37. Configure the KMS backing KeyProvider properties
  38. in the <<<etc/hadoop/kms-site.xml>>> configuration file:
  39. +---+
  40. <property>
  41. <name>hadoop.security.key.provider.path</name>
  42. <value>jceks://file@/${user.home}/kms.keystore</value>
  43. </property>
  44. <property>
  45. <name>hadoop.security.keystore.java-keystore-provider.password-file</name>
  46. <value>kms.keystore.password</value>
  47. </property>
  48. +---+
  49. The password file is looked up in the Hadoop's configuration directory via the
  50. classpath.
  51. NOTE: You need to restart the KMS for the configuration changes to take
  52. effect.
  53. ** KMS Cache
  54. KMS caches keys for short period of time to avoid excessive hits to the
  55. underlying key provider.
  56. The Cache is enabled by default (can be dissabled by setting the
  57. <<<hadoop.kms.cache.enable>>> boolean property to false)
  58. The cache is used with the following 3 methods only, <<<getCurrentKey()>>>
  59. and <<<getKeyVersion()>>> and <<<getMetadata()>>>.
  60. For the <<<getCurrentKey()>>> method, cached entries are kept for a maximum
  61. of 30000 millisecond regardless the number of times the key is being access
  62. (to avoid stale keys to be considered current).
  63. For the <<<getKeyVersion()>>> method, cached entries are kept with a default
  64. inactivity timeout of 600000 milliseconds (10 mins). This time out is
  65. configurable via the following property in the <<<etc/hadoop/kms-site.xml>>>
  66. configuration file:
  67. +---+
  68. <property>
  69. <name>hadoop.kms.cache.enable</name>
  70. <value>true</value>
  71. </property>
  72. <property>
  73. <name>hadoop.kms.cache.timeout.ms</name>
  74. <value>600000</value>
  75. </property>
  76. <property>
  77. <name>hadoop.kms.current.key.cache.timeout.ms</name>
  78. <value>30000</value>
  79. </property>
  80. +---+
  81. ** KMS Aggregated Audit logs
  82. Audit logs are aggregated for API accesses to the GET_KEY_VERSION,
  83. GET_CURRENT_KEY, DECRYPT_EEK, GENERATE_EEK operations.
  84. Entries are grouped by the (user,key,operation) combined key for a
  85. configurable aggregation interval after which the number of accesses to the
  86. specified end-point by the user for a given key is flushed to the audit log.
  87. The Aggregation interval is configured via the property :
  88. +---+
  89. <property>
  90. <name>hadoop.kms.aggregation.delay.ms</name>
  91. <value>10000</value>
  92. </property>
  93. +---+
  94. ** Start/Stop the KMS
  95. To start/stop KMS use KMS's bin/kms.sh script. For example:
  96. +---+
  97. hadoop-${project.version} $ sbin/kms.sh start
  98. +---+
  99. NOTE: Invoking the script without any parameters list all possible
  100. parameters (start, stop, run, etc.). The <<<kms.sh>>> script is a wrapper
  101. for Tomcat's <<<catalina.sh>>> script that sets the environment variables
  102. and Java System properties required to run KMS.
  103. ** Embedded Tomcat Configuration
  104. To configure the embedded Tomcat go to the <<<share/hadoop/kms/tomcat/conf>>>.
  105. KMS pre-configures the HTTP and Admin ports in Tomcat's <<<server.xml>>> to
  106. 16000 and 16001.
  107. Tomcat logs are also preconfigured to go to Hadoop's <<<logs/>>> directory.
  108. The following environment variables (which can be set in KMS's
  109. <<<etc/hadoop/kms-env.sh>>> script) can be used to alter those values:
  110. * KMS_HTTP_PORT
  111. * KMS_ADMIN_PORT
  112. * KMS_LOG
  113. NOTE: You need to restart the KMS for the configuration changes to take
  114. effect.
  115. ** KMS Security Configuration
  116. *** Enabling Kerberos HTTP SPNEGO Authentication
  117. Configure the Kerberos <<<etc/krb5.conf>>> file with the information of your
  118. KDC server.
  119. Create a service principal and its keytab for the KMS, it must be an
  120. <<<HTTP>>> service principal.
  121. Configure KMS <<<etc/hadoop/kms-site.xml>>> with the correct security values,
  122. for example:
  123. +---+
  124. <property>
  125. <name>hadoop.kms.authentication.type</name>
  126. <value>kerberos</value>
  127. </property>
  128. <property>
  129. <name>hadoop.kms.authentication.kerberos.keytab</name>
  130. <value>${user.home}/kms.keytab</value>
  131. </property>
  132. <property>
  133. <name>hadoop.kms.authentication.kerberos.principal</name>
  134. <value>HTTP/localhost</value>
  135. </property>
  136. <property>
  137. <name>hadoop.kms.authentication.kerberos.name.rules</name>
  138. <value>DEFAULT</value>
  139. </property>
  140. +---+
  141. NOTE: You need to restart the KMS for the configuration changes to take
  142. effect.
  143. *** KMS over HTTPS (SSL)
  144. To configure KMS to work over HTTPS the following 2 properties must be
  145. set in the <<<etc/hadoop/kms_env.sh>>> script (shown with default values):
  146. * KMS_SSL_KEYSTORE_FILE=${HOME}/.keystore
  147. * KMS_SSL_KEYSTORE_PASS=password
  148. In the KMS <<<tomcat/conf>>> directory, replace the <<<server.xml>>> file
  149. with the provided <<<ssl-server.xml>>> file.
  150. You need to create an SSL certificate for the KMS. As the
  151. <<<kms>>> Unix user, using the Java <<<keytool>>> command to create the
  152. SSL certificate:
  153. +---+
  154. $ keytool -genkey -alias tomcat -keyalg RSA
  155. +---+
  156. You will be asked a series of questions in an interactive prompt. It will
  157. create the keystore file, which will be named <<.keystore>> and located in the
  158. <<<kms>>> user home directory.
  159. The password you enter for "keystore password" must match the value of the
  160. <<<KMS_SSL_KEYSTORE_PASS>>> environment variable set in the
  161. <<<kms-env.sh>>> script in the configuration directory.
  162. The answer to "What is your first and last name?" (i.e. "CN") must be the
  163. hostname of the machine where the KMS will be running.
  164. NOTE: You need to restart the KMS for the configuration changes to take
  165. effect.
  166. *** KMS Access Control
  167. KMS ACLs configuration are defined in the KMS <<<etc/hadoop/kms-acls.xml>>>
  168. configuration file. This file is hot-reloaded when it changes.
  169. KMS supports a fine grained access control via a set ACL
  170. configuration properties:
  171. +---+
  172. <property>
  173. <name>hadoop.kms.acl.CREATE</name>
  174. <value>*</value>
  175. <description>
  176. ACL for create-key operations.
  177. If the user does is not in the GET ACL, the key material is not returned
  178. as part of the response.
  179. </description>
  180. </property>
  181. <property>
  182. <name>hadoop.kms.acl.DELETE</name>
  183. <value>*</value>
  184. <description>
  185. ACL for delete-key operations.
  186. </description>
  187. </property>
  188. <property>
  189. <name>hadoop.kms.acl.ROLLOVER</name>
  190. <value>*</value>
  191. <description>
  192. ACL for rollover-key operations.
  193. If the user does is not in the GET ACL, the key material is not returned
  194. as part of the response.
  195. </description>
  196. </property>
  197. <property>
  198. <name>hadoop.kms.acl.GET</name>
  199. <value>*</value>
  200. <description>
  201. ACL for get-key-version and get-current-key operations.
  202. </description>
  203. </property>
  204. <property>
  205. <name>hadoop.kms.acl.GET_KEYS</name>
  206. <value>*</value>
  207. <description>
  208. ACL for get-keys operation.
  209. </description>
  210. </property>
  211. <property>
  212. <name>hadoop.kms.acl.GET_METADATA</name>
  213. <value>*</value>
  214. <description>
  215. ACL for get-key-metadata and get-keys-metadata operations.
  216. </description>
  217. </property>
  218. <property>
  219. <name>hadoop.kms.acl.SET_KEY_MATERIAL</name>
  220. <value>*</value>
  221. <description>
  222. Complimentary ACL for CREATE and ROLLOVER operation to allow the client
  223. to provide the key material when creating or rolling a key.
  224. </description>
  225. </property>
  226. <property>
  227. <name>hadoop.kms.acl.GENERATE_EEK</name>
  228. <value>*</value>
  229. <description>
  230. ACL for generateEncryptedKey
  231. CryptoExtension operations
  232. </description>
  233. </property>
  234. <property>
  235. <name>hadoop.kms.acl.DECRYPT_EEK</name>
  236. <value>*</value>
  237. <description>
  238. ACL for decrypt EncryptedKey
  239. CryptoExtension operations
  240. </description>
  241. </property>
  242. </configuration>
  243. +---+
  244. ** KMS HTTP REST API
  245. *** Create a Key
  246. <REQUEST:>
  247. +---+
  248. POST http://HOST:PORT/kms/v1/keys
  249. Content-Type: application/json
  250. {
  251. "name" : "<key-name>",
  252. "cipher" : "<cipher>",
  253. "length" : <length>, //int
  254. "material" : "<material>", //base64
  255. "description" : "<description>"
  256. }
  257. +---+
  258. <RESPONSE:>
  259. +---+
  260. 201 CREATED
  261. LOCATION: http://HOST:PORT/kms/v1/key/<key-name>
  262. Content-Type: application/json
  263. {
  264. "name" : "versionName",
  265. "material" : "<material>", //base64, not present without GET ACL
  266. }
  267. +---+
  268. *** Rollover Key
  269. <REQUEST:>
  270. +---+
  271. POST http://HOST:PORT/kms/v1/key/<key-name>
  272. Content-Type: application/json
  273. {
  274. "material" : "<material>",
  275. }
  276. +---+
  277. <RESPONSE:>
  278. +---+
  279. 200 OK
  280. Content-Type: application/json
  281. {
  282. "name" : "versionName",
  283. "material" : "<material>", //base64, not present without GET ACL
  284. }
  285. +---+
  286. *** Delete Key
  287. <REQUEST:>
  288. +---+
  289. DELETE http://HOST:PORT/kms/v1/key/<key-name>
  290. +---+
  291. <RESPONSE:>
  292. +---+
  293. 200 OK
  294. +---+
  295. *** Get Key Metadata
  296. <REQUEST:>
  297. +---+
  298. GET http://HOST:PORT/kms/v1/key/<key-name>/_metadata
  299. +---+
  300. <RESPONSE:>
  301. +---+
  302. 200 OK
  303. Content-Type: application/json
  304. {
  305. "name" : "<key-name>",
  306. "cipher" : "<cipher>",
  307. "length" : <length>, //int
  308. "description" : "<description>",
  309. "created" : <millis-epoc>, //long
  310. "versions" : <versions> //int
  311. }
  312. +---+
  313. *** Get Current Key
  314. <REQUEST:>
  315. +---+
  316. GET http://HOST:PORT/kms/v1/key/<key-name>/_currentversion
  317. +---+
  318. <RESPONSE:>
  319. +---+
  320. 200 OK
  321. Content-Type: application/json
  322. {
  323. "name" : "versionName",
  324. "material" : "<material>", //base64
  325. }
  326. +---+
  327. *** Generate Encrypted Key for Current KeyVersion
  328. <REQUEST:>
  329. +---+
  330. GET http://HOST:PORT/kms/v1/key/<key-name>/_eek?eek_op=generate&num_keys=<number-of-keys-to-generate>
  331. +---+
  332. <RESPONSE:>
  333. +---+
  334. 200 OK
  335. Content-Type: application/json
  336. [
  337. {
  338. "versionName" : "encryptionVersionName",
  339. "iv" : "<iv>", //base64
  340. "encryptedKeyVersion" : {
  341. "versionName" : "EEK",
  342. "material" : "<material>", //base64
  343. }
  344. },
  345. {
  346. "versionName" : "encryptionVersionName",
  347. "iv" : "<iv>", //base64
  348. "encryptedKeyVersion" : {
  349. "versionName" : "EEK",
  350. "material" : "<material>", //base64
  351. }
  352. },
  353. ...
  354. ]
  355. +---+
  356. *** Decrypt Encrypted Key
  357. <REQUEST:>
  358. +---+
  359. POST http://HOST:PORT/kms/v1/keyversion/<version-name>/_eek?ee_op=decrypt
  360. Content-Type: application/json
  361. {
  362. "name" : "<key-name>",
  363. "iv" : "<iv>", //base64
  364. "material" : "<material>", //base64
  365. }
  366. +---+
  367. <RESPONSE:>
  368. +---+
  369. 200 OK
  370. Content-Type: application/json
  371. {
  372. "name" : "EK",
  373. "material" : "<material>", //base64
  374. }
  375. +---+
  376. *** Get Key Version
  377. <REQUEST:>
  378. +---+
  379. GET http://HOST:PORT/kms/v1/keyversion/<version-name>
  380. +---+
  381. <RESPONSE:>
  382. +---+
  383. 200 OK
  384. Content-Type: application/json
  385. {
  386. "name" : "versionName",
  387. "material" : "<material>", //base64
  388. }
  389. +---+
  390. *** Get Key Versions
  391. <REQUEST:>
  392. +---+
  393. GET http://HOST:PORT/kms/v1/key/<key-name>/_versions
  394. +---+
  395. <RESPONSE:>
  396. +---+
  397. 200 OK
  398. Content-Type: application/json
  399. [
  400. {
  401. "name" : "versionName",
  402. "material" : "<material>", //base64
  403. },
  404. {
  405. "name" : "versionName",
  406. "material" : "<material>", //base64
  407. },
  408. ...
  409. ]
  410. +---+
  411. *** Get Key Names
  412. <REQUEST:>
  413. +---+
  414. GET http://HOST:PORT/kms/v1/keys/names
  415. +---+
  416. <RESPONSE:>
  417. +---+
  418. 200 OK
  419. Content-Type: application/json
  420. [
  421. "<key-name>",
  422. "<key-name>",
  423. ...
  424. ]
  425. +---+
  426. *** Get Keys Metadata
  427. +---+
  428. GET http://HOST:PORT/kms/v1/keys/metadata?key=<key-name>&key=<key-name>,...
  429. +---+
  430. <RESPONSE:>
  431. +---+
  432. 200 OK
  433. Content-Type: application/json
  434. [
  435. {
  436. "name" : "<key-name>",
  437. "cipher" : "<cipher>",
  438. "length" : <length>, //int
  439. "description" : "<description>",
  440. "created" : <millis-epoc>, //long
  441. "versions" : <versions> //int
  442. },
  443. {
  444. "name" : "<key-name>",
  445. "cipher" : "<cipher>",
  446. "length" : <length>, //int
  447. "description" : "<description>",
  448. "created" : <millis-epoc>, //long
  449. "versions" : <versions> //int
  450. },
  451. ...
  452. ]
  453. +---+