index.md.vm 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  1. <!---
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License. See accompanying LICENSE file.
  11. -->
  12. #set ( $H3 = '###' )
  13. #set ( $H4 = '####' )
  14. #set ( $H5 = '#####' )
  15. Hadoop Key Management Server (KMS) - Documentation Sets
  16. =======================================================
  17. Hadoop KMS is a cryptographic key management server based on Hadoop's **KeyProvider** API.
  18. It provides a client and a server components which communicate over HTTP using a REST API.
  19. The client is a KeyProvider implementation interacts with the KMS using the KMS HTTP REST API.
  20. KMS and its client have built-in security and they support HTTP SPNEGO Kerberos authentication and HTTPS secure transport.
  21. KMS is a Java web-application and it runs using a pre-configured Tomcat bundled with the Hadoop distribution.
  22. KMS Client Configuration
  23. ------------------------
  24. The KMS client `KeyProvider` uses the **kms** scheme, and the embedded URL must be the URL of the KMS. For example, for a KMS running on `http://localhost:16000/kms`, the KeyProvider URI is `kms://http@localhost:16000/kms`. And, for a KMS running on `https://localhost:16000/kms`, the KeyProvider URI is `kms://https@localhost:16000/kms`
  25. KMS
  26. ---
  27. $H3 KMS Configuration
  28. Configure the KMS backing KeyProvider properties in the `etc/hadoop/kms-site.xml` configuration file:
  29. ```xml
  30. <property>
  31. <name>hadoop.kms.key.provider.uri</name>
  32. <value>jceks://file@/${user.home}/kms.keystore</value>
  33. </property>
  34. <property>
  35. <name>hadoop.security.keystore.java-keystore-provider.password-file</name>
  36. <value>kms.keystore.password</value>
  37. </property>
  38. ```
  39. The password file is looked up in the Hadoop's configuration directory via the classpath.
  40. NOTE: You need to restart the KMS for the configuration changes to take effect.
  41. $H3 KMS Cache
  42. KMS has two kinds of caching: a CachingKeyProvider for caching the encryption keys, and a KeyProvider for caching the EEKs.
  43. $H4 CachingKeyProvider
  44. KMS caches encryption keys for a short period of time to avoid excessive hits to the underlying KeyProvider.
  45. This Cache is enabled by default (can be disabled by setting the `hadoop.kms.cache.enable` boolean property to false)
  46. This cache is used with the following 3 methods only, `getCurrentKey()` and `getKeyVersion()` and `getMetadata()`.
  47. For the `getCurrentKey()` method, cached entries are kept for a maximum of 30000 milliseconds regardless the number of times the key is being accessed (to avoid stale keys to be considered current).
  48. For the `getKeyVersion()` method, cached entries are kept with a default inactivity timeout of 600000 milliseconds (10 mins).
  49. These configurations can be changed via the following properties in the `etc/hadoop/kms-site.xml` configuration file:
  50. ```xml
  51. <property>
  52. <name>hadoop.kms.cache.enable</name>
  53. <value>true</value>
  54. </property>
  55. <property>
  56. <name>hadoop.kms.cache.timeout.ms</name>
  57. <value>600000</value>
  58. </property>
  59. <property>
  60. <name>hadoop.kms.current.key.cache.timeout.ms</name>
  61. <value>30000</value>
  62. </property>
  63. ```
  64. $H4 KeyProvider
  65. Architecturally, both server-side (e.g. KMS) and client-side (e.g. NameNode) have a cache for EEKs. The following are configurable on the cache:
  66. * The size of the cache. This is the maximum number of EEKs that can be cached under each key name.
  67. * A low watermark on the cache. For each key name, if after a get call, the number of cached EEKs are less than (size * low watermark), then the cache under this key name will be filled asynchronously. For each key name, only 1 thread could be running for the asynchronous filling.
  68. * The maximum number of asynchronous threads overall, across key names, allowed to fill the queue in a cache.
  69. * The cache expiry time, in milliseconds. Internally Guava cache is used as the cache implementation. The expiry approach is [expireAfterAccess](https://code.google.com/p/guava-libraries/wiki/CachesExplained).
  70. Note that due to the asynchronous filling mechanism, it is possible that after rollNewVersion(), the caller still gets the old EEKs. In the worst case, the caller may get up to (server-side cache size + client-side cache size) number of old EEKs, or until both caches expire. This behavior is a trade off to avoid locking on the cache, and is acceptable since the old version EEKs can still be used to decrypt.
  71. Below are the configurations and their default values:
  72. Server-side can be changed via the following properties in the `etc/hadoop/kms-site.xml` configuration file:
  73. ```xml
  74. <property>
  75. <name>hadoop.security.kms.encrypted.key.cache.size</name>
  76. <value>500</value>
  77. </property>
  78. <property>
  79. <name>hadoop.security.kms.encrypted.key.cache.low.watermark</name>
  80. <value>0.3</value>
  81. </property>
  82. <property>
  83. <name>hadoop.security.kms.encrypted.key.cache.num.fill.threads</name>
  84. <value>2</value>
  85. </property>
  86. <property>
  87. <name>hadoop.security.kms.encrypted.key.cache.expiry</name>
  88. <value>43200000</value>
  89. </property>
  90. ```
  91. Client-side can be changed via the following properties in the `etc/hadoop/core-site.xml` configuration file:
  92. ```xml
  93. <property>
  94. <name>hadoop.security.kms.client.encrypted.key.cache.size</name>
  95. <value>500</value>
  96. </property>
  97. <property>
  98. <name>hadoop.security.kms.client.encrypted.key.cache.low-watermark</name>
  99. <value>0.3</value>
  100. </property>
  101. <property>
  102. <name>hadoop.security.kms.client.encrypted.key.cache.num.refill.threads</name>
  103. <value>2</value>
  104. </property>
  105. <property>
  106. <name>hadoop.security.kms.client.encrypted.key.cache.expiry</name>
  107. <value>43200000</value>
  108. </property>
  109. ```
  110. $H3 KMS Aggregated Audit logs
  111. Audit logs are aggregated for API accesses to the GET\_KEY\_VERSION, GET\_CURRENT\_KEY, DECRYPT\_EEK, GENERATE\_EEK operations.
  112. Entries are grouped by the (user,key,operation) combined key for a configurable aggregation interval after which the number of accesses to the specified end-point by the user for a given key is flushed to the audit log.
  113. The Aggregation interval is configured via the property :
  114. <property>
  115. <name>hadoop.kms.aggregation.delay.ms</name>
  116. <value>10000</value>
  117. </property>
  118. $H3 Start/Stop the KMS
  119. To start/stop KMS use KMS's sbin/kms.sh script. For example:
  120. hadoop-${project.version} $ sbin/kms.sh start
  121. NOTE: Invoking the script without any parameters list all possible parameters (start, stop, run, etc.). The `kms.sh` script is a wrapper for Tomcat's `catalina.sh` script that sets the environment variables and Java System properties required to run KMS.
  122. $H3 Embedded Tomcat Configuration
  123. To configure the embedded Tomcat go to the `share/hadoop/kms/tomcat/conf`.
  124. KMS pre-configures the HTTP and Admin ports in Tomcat's `server.xml` to 16000 and 16001.
  125. Tomcat logs are also preconfigured to go to Hadoop's `logs/` directory.
  126. The following environment variables (which can be set in KMS's `etc/hadoop/kms-env.sh` script) can be used to alter those values:
  127. * KMS_HTTP_PORT
  128. * KMS_ADMIN_PORT
  129. * KMS_MAX_THREADS
  130. * KMS_MAX_HTTP_HEADER_SIZE
  131. * KMS_LOGNOTE: You need to restart the KMS for the configuration changes to take effect.
  132. $H3 Loading native libraries
  133. The following environment variable (which can be set in KMS's `etc/hadoop/kms-env.sh` script) can be used to specify the location of any required native libraries. For eg. Tomact native Apache Portable Runtime (APR) libraries:
  134. * JAVA_LIBRARY_PATH
  135. $H3 KMS Security Configuration
  136. $H4 Enabling Kerberos HTTP SPNEGO Authentication
  137. Configure the Kerberos `etc/krb5.conf` file with the information of your KDC server.
  138. Create a service principal and its keytab for the KMS, it must be an `HTTP` service principal.
  139. Configure KMS `etc/hadoop/kms-site.xml` with the correct security values, for example:
  140. ```xml
  141. <property>
  142. <name>hadoop.kms.authentication.type</name>
  143. <value>kerberos</value>
  144. </property>
  145. <property>
  146. <name>hadoop.kms.authentication.kerberos.keytab</name>
  147. <value>${user.home}/kms.keytab</value>
  148. </property>
  149. <property>
  150. <name>hadoop.kms.authentication.kerberos.principal</name>
  151. <value>HTTP/localhost</value>
  152. </property>
  153. <property>
  154. <name>hadoop.kms.authentication.kerberos.name.rules</name>
  155. <value>DEFAULT</value>
  156. </property>
  157. ```
  158. NOTE: You need to restart the KMS for the configuration changes to take effect.
  159. $H4 KMS Proxyuser Configuration
  160. Each proxyuser must be configured in `etc/hadoop/kms-site.xml` using the following properties:
  161. ```xml
  162. <property>
  163. <name>hadoop.kms.proxyuser.#USER#.users</name>
  164. <value>*</value>
  165. </property>
  166. <property>
  167. <name>hadoop.kms.proxyuser.#USER#.groups</name>
  168. <value>*</value>
  169. </property>
  170. <property>
  171. <name>hadoop.kms.proxyuser.#USER#.hosts</name>
  172. <value>*</value>
  173. </property>
  174. ```
  175. `#USER#` is the username of the proxyuser to configure.
  176. The `users` property indicates the users that can be impersonated.
  177. The `groups` property indicates the groups users being impersonated must belong to.
  178. At least one of the `users` or `groups` properties must be defined. If both are specified, then the configured proxyuser will be able to impersonate and user in the `users` list and any user belonging to one of the groups in the `groups` list.
  179. The `hosts` property indicates from which host the proxyuser can make impersonation requests.
  180. If `users`, `groups` or `hosts` has a `*`, it means there are no restrictions for the proxyuser regarding users, groups or hosts.
  181. $H4 KMS over HTTPS (SSL)
  182. To configure KMS to work over HTTPS the following 2 properties must be set in the `etc/hadoop/kms_env.sh` script (shown with default values):
  183. * KMS_SSL_KEYSTORE_FILE=$HOME/.keystore
  184. * KMS_SSL_KEYSTORE_PASS=password
  185. In the KMS `tomcat/conf` directory, replace the `server.xml` file with the provided `ssl-server.xml` file.
  186. You need to create an SSL certificate for the KMS. As the `kms` Unix user, using the Java `keytool` command to create the SSL certificate:
  187. $ keytool -genkey -alias tomcat -keyalg RSA
  188. You will be asked a series of questions in an interactive prompt. It will create the keystore file, which will be named **.keystore** and located in the `kms` user home directory.
  189. The password you enter for "keystore password" must match the value of the `KMS_SSL_KEYSTORE_PASS` environment variable set in the `kms-env.sh` script in the configuration directory.
  190. The answer to "What is your first and last name?" (i.e. "CN") must be the hostname of the machine where the KMS will be running.
  191. NOTE: You need to restart the KMS for the configuration changes to take effect.
  192. $H4 KMS Access Control
  193. KMS ACLs configuration are defined in the KMS `etc/hadoop/kms-acls.xml` configuration file. This file is hot-reloaded when it changes.
  194. KMS supports both fine grained access control as well as blacklist for kms operations via a set ACL configuration properties.
  195. A user accessing KMS is first checked for inclusion in the Access Control List for the requested operation and then checked for exclusion in the Black list for the operation before access is granted.
  196. ```xml
  197. <configuration>
  198. <property>
  199. <name>hadoop.kms.acl.CREATE</name>
  200. <value>*</value>
  201. <description>
  202. ACL for create-key operations.
  203. If the user is not in the GET ACL, the key material is not returned
  204. as part of the response.
  205. </description>
  206. </property>
  207. <property>
  208. <name>hadoop.kms.blacklist.CREATE</name>
  209. <value>hdfs,foo</value>
  210. <description>
  211. Blacklist for create-key operations.
  212. If the user is in the Blacklist, the key material is not returned
  213. as part of the response.
  214. </description>
  215. </property>
  216. <property>
  217. <name>hadoop.kms.acl.DELETE</name>
  218. <value>*</value>
  219. <description>
  220. ACL for delete-key operations.
  221. </description>
  222. </property>
  223. <property>
  224. <name>hadoop.kms.blacklist.DELETE</name>
  225. <value>hdfs,foo</value>
  226. <description>
  227. Blacklist for delete-key operations.
  228. </description>
  229. </property>
  230. <property>
  231. <name>hadoop.kms.acl.ROLLOVER</name>
  232. <value>*</value>
  233. <description>
  234. ACL for rollover-key operations.
  235. If the user is not in the GET ACL, the key material is not returned
  236. as part of the response.
  237. </description>
  238. </property>
  239. <property>
  240. <name>hadoop.kms.blacklist.ROLLOVER</name>
  241. <value>hdfs,foo</value>
  242. <description>
  243. Blacklist for rollover-key operations.
  244. </description>
  245. </property>
  246. <property>
  247. <name>hadoop.kms.acl.GET</name>
  248. <value>*</value>
  249. <description>
  250. ACL for get-key-version and get-current-key operations.
  251. </description>
  252. </property>
  253. <property>
  254. <name>hadoop.kms.blacklist.GET</name>
  255. <value>hdfs,foo</value>
  256. <description>
  257. ACL for get-key-version and get-current-key operations.
  258. </description>
  259. </property>
  260. <property>
  261. <name>hadoop.kms.acl.GET_KEYS</name>
  262. <value>*</value>
  263. <description>
  264. ACL for get-keys operation.
  265. </description>
  266. </property>
  267. <property>
  268. <name>hadoop.kms.blacklist.GET_KEYS</name>
  269. <value>hdfs,foo</value>
  270. <description>
  271. Blacklist for get-keys operation.
  272. </description>
  273. </property>
  274. <property>
  275. <name>hadoop.kms.acl.GET_METADATA</name>
  276. <value>*</value>
  277. <description>
  278. ACL for get-key-metadata and get-keys-metadata operations.
  279. </description>
  280. </property>
  281. <property>
  282. <name>hadoop.kms.blacklist.GET_METADATA</name>
  283. <value>hdfs,foo</value>
  284. <description>
  285. Blacklist for get-key-metadata and get-keys-metadata operations.
  286. </description>
  287. </property>
  288. <property>
  289. <name>hadoop.kms.acl.SET_KEY_MATERIAL</name>
  290. <value>*</value>
  291. <description>
  292. Complimentary ACL for CREATE and ROLLOVER operation to allow the client
  293. to provide the key material when creating or rolling a key.
  294. </description>
  295. </property>
  296. <property>
  297. <name>hadoop.kms.blacklist.SET_KEY_MATERIAL</name>
  298. <value>hdfs,foo</value>
  299. <description>
  300. Complimentary Blacklist for CREATE and ROLLOVER operation to allow the client
  301. to provide the key material when creating or rolling a key.
  302. </description>
  303. </property>
  304. <property>
  305. <name>hadoop.kms.acl.GENERATE_EEK</name>
  306. <value>*</value>
  307. <description>
  308. ACL for generateEncryptedKey
  309. CryptoExtension operations
  310. </description>
  311. </property>
  312. <property>
  313. <name>hadoop.kms.blacklist.GENERATE_EEK</name>
  314. <value>hdfs,foo</value>
  315. <description>
  316. Blacklist for generateEncryptedKey
  317. CryptoExtension operations
  318. </description>
  319. </property>
  320. <property>
  321. <name>hadoop.kms.acl.DECRYPT_EEK</name>
  322. <value>*</value>
  323. <description>
  324. ACL for decrypt EncryptedKey
  325. CryptoExtension operations
  326. </description>
  327. </property>
  328. <property>
  329. <name>hadoop.kms.blacklist.DECRYPT_EEK</name>
  330. <value>hdfs,foo</value>
  331. <description>
  332. Blacklist for decrypt EncryptedKey
  333. CryptoExtension operations
  334. </description>
  335. </property>
  336. </configuration>
  337. ```
  338. $H4 Key Access Control
  339. KMS supports access control for all non-read operations at the Key level. All Key Access operations are classified as :
  340. * MANAGEMENT - createKey, deleteKey, rolloverNewVersion
  341. * GENERATE_EEK - generateEncryptedKey, warmUpEncryptedKeys
  342. * DECRYPT_EEK - decryptEncryptedKey
  343. * READ - getKeyVersion, getKeyVersions, getMetadata, getKeysMetadata, getCurrentKey
  344. * ALL - all of the above
  345. These can be defined in the KMS `etc/hadoop/kms-acls.xml` as follows
  346. For all keys for which a key access has not been explicitly configured, It is possible to configure a default key access control for a subset of the operation types.
  347. It is also possible to configure a "whitelist" key ACL for a subset of the operation types. The whitelist key ACL is a whitelist in addition to the explicit or default per-key ACL. That is, if no per-key ACL is explicitly set, a user will be granted access if they are present in the default per-key ACL or the whitelist key ACL. If a per-key ACL is explicitly set, a user will be granted access if they are present in the per-key ACL or the whitelist key ACL.
  348. If no ACL is configured for a specific key AND no default ACL is configured AND no root key ACL is configured for the requested operation, then access will be DENIED.
  349. **NOTE:** The default and whitelist key ACL does not support `ALL` operation qualifier.
  350. ```xml
  351. <property>
  352. <name>key.acl.testKey1.MANAGEMENT</name>
  353. <value>*</value>
  354. <description>
  355. ACL for create-key, deleteKey and rolloverNewVersion operations.
  356. </description>
  357. </property>
  358. <property>
  359. <name>key.acl.testKey2.GENERATE_EEK</name>
  360. <value>*</value>
  361. <description>
  362. ACL for generateEncryptedKey operations.
  363. </description>
  364. </property>
  365. <property>
  366. <name>key.acl.testKey3.DECRYPT_EEK</name>
  367. <value>admink3</value>
  368. <description>
  369. ACL for decryptEncryptedKey operations.
  370. </description>
  371. </property>
  372. <property>
  373. <name>key.acl.testKey4.READ</name>
  374. <value>*</value>
  375. <description>
  376. ACL for getKeyVersion, getKeyVersions, getMetadata, getKeysMetadata,
  377. getCurrentKey operations
  378. </description>
  379. </property>
  380. <property>
  381. <name>key.acl.testKey5.ALL</name>
  382. <value>*</value>
  383. <description>
  384. ACL for ALL operations.
  385. </description>
  386. </property>
  387. <property>
  388. <name>whitelist.key.acl.MANAGEMENT</name>
  389. <value>admin1</value>
  390. <description>
  391. whitelist ACL for MANAGEMENT operations for all keys.
  392. </description>
  393. </property>
  394. <!--
  395. 'testKey3' key ACL is defined. Since a 'whitelist'
  396. key is also defined for DECRYPT_EEK, in addition to
  397. admink3, admin1 can also perform DECRYPT_EEK operations
  398. on 'testKey3'
  399. -->
  400. <property>
  401. <name>whitelist.key.acl.DECRYPT_EEK</name>
  402. <value>admin1</value>
  403. <description>
  404. whitelist ACL for DECRYPT_EEK operations for all keys.
  405. </description>
  406. </property>
  407. <property>
  408. <name>default.key.acl.MANAGEMENT</name>
  409. <value>user1,user2</value>
  410. <description>
  411. default ACL for MANAGEMENT operations for all keys that are not
  412. explicitly defined.
  413. </description>
  414. </property>
  415. <property>
  416. <name>default.key.acl.GENERATE_EEK</name>
  417. <value>user1,user2</value>
  418. <description>
  419. default ACL for GENERATE_EEK operations for all keys that are not
  420. explicitly defined.
  421. </description>
  422. </property>
  423. <property>
  424. <name>default.key.acl.DECRYPT_EEK</name>
  425. <value>user1,user2</value>
  426. <description>
  427. default ACL for DECRYPT_EEK operations for all keys that are not
  428. explicitly defined.
  429. </description>
  430. </property>
  431. <property>
  432. <name>default.key.acl.READ</name>
  433. <value>user1,user2</value>
  434. <description>
  435. default ACL for READ operations for all keys that are not
  436. explicitly defined.
  437. </description>
  438. </property>
  439. ```
  440. $H3 KMS Delegation Token Configuration
  441. KMS delegation token secret manager can be configured with the following properties:
  442. ```xml
  443. <property>
  444. <name>hadoop.kms.authentication.delegation-token.update-interval.sec</name>
  445. <value>86400</value>
  446. <description>
  447. How often the master key is rotated, in seconds. Default value 1 day.
  448. </description>
  449. </property>
  450. <property>
  451. <name>hadoop.kms.authentication.delegation-token.max-lifetime.sec</name>
  452. <value>604800</value>
  453. <description>
  454. Maximum lifetime of a delagation token, in seconds. Default value 7 days.
  455. </description>
  456. </property>
  457. <property>
  458. <name>hadoop.kms.authentication.delegation-token.renew-interval.sec</name>
  459. <value>86400</value>
  460. <description>
  461. Renewal interval of a delagation token, in seconds. Default value 1 day.
  462. </description>
  463. </property>
  464. <property>
  465. <name>hadoop.kms.authentication.delegation-token.removal-scan-interval.sec</name>
  466. <value>3600</value>
  467. <description>
  468. Scan interval to remove expired delegation tokens.
  469. </description>
  470. </property>
  471. ```
  472. $H3 Using Multiple Instances of KMS Behind a Load-Balancer or VIP
  473. KMS supports multiple KMS instances behind a load-balancer or VIP for scalability and for HA purposes.
  474. When using multiple KMS instances behind a load-balancer or VIP, requests from the same user may be handled by different KMS instances.
  475. KMS instances behind a load-balancer or VIP must be specially configured to work properly as a single logical service.
  476. $H4 HTTP Kerberos Principals Configuration
  477. When KMS instances are behind a load-balancer or VIP, clients will use the hostname of the VIP. For Kerberos SPNEGO authentication, the hostname of the URL is used to construct the Kerberos service name of the server, `HTTP/#HOSTNAME#`. This means that all KMS instances must have a Kerberos service name with the load-balancer or VIP hostname.
  478. In order to be able to access directly a specific KMS instance, the KMS instance must also have Keberos service name with its own hostname. This is required for monitoring and admin purposes.
  479. Both Kerberos service principal credentials (for the load-balancer/VIP hostname and for the actual KMS instance hostname) must be in the keytab file configured for authentication. And the principal name specified in the configuration must be '\*'. For example:
  480. ```xml
  481. <property>
  482. <name>hadoop.kms.authentication.kerberos.principal</name>
  483. <value>*</value>
  484. </property>
  485. ```
  486. **NOTE:** If using HTTPS, the SSL certificate used by the KMS instance must be configured to support multiple hostnames (see Java 7 `keytool` SAN extension support for details on how to do this).
  487. $H4 HTTP Authentication Signature
  488. KMS uses Hadoop Authentication for HTTP authentication. Hadoop Authentication issues a signed HTTP Cookie once the client has authenticated successfully. This HTTP Cookie has an expiration time, after which it will trigger a new authentication sequence. This is done to avoid triggering the authentication on every HTTP request of a client.
  489. A KMS instance must verify the HTTP Cookie signatures signed by other KMS instances. To do this all KMS instances must share the signing secret.
  490. This secret sharing can be done using a Zookeeper service which is configured in KMS with the following properties in the `kms-site.xml`:
  491. ```xml
  492. <property>
  493. <name>hadoop.kms.authentication.signer.secret.provider</name>
  494. <value>zookeeper</value>
  495. <description>
  496. Indicates how the secret to sign the authentication cookies will be
  497. stored. Options are 'random' (default), 'string' and 'zookeeper'.
  498. If using a setup with multiple KMS instances, 'zookeeper' should be used.
  499. </description>
  500. </property>
  501. <property>
  502. <name>hadoop.kms.authentication.signer.secret.provider.zookeeper.path</name>
  503. <value>/hadoop-kms/hadoop-auth-signature-secret</value>
  504. <description>
  505. The Zookeeper ZNode path where the KMS instances will store and retrieve
  506. the secret from.
  507. </description>
  508. </property>
  509. <property>
  510. <name>hadoop.kms.authentication.signer.secret.provider.zookeeper.connection.string</name>
  511. <value>#HOSTNAME#:#PORT#,...</value>
  512. <description>
  513. The Zookeeper connection string, a list of hostnames and port comma
  514. separated.
  515. </description>
  516. </property>
  517. <property>
  518. <name>hadoop.kms.authentication.signer.secret.provider.zookeeper.auth.type</name>
  519. <value>kerberos</value>
  520. <description>
  521. The Zookeeper authentication type, 'none' or 'sasl' (Kerberos).
  522. </description>
  523. </property>
  524. <property>
  525. <name>hadoop.kms.authentication.signer.secret.provider.zookeeper.kerberos.keytab</name>
  526. <value>/etc/hadoop/conf/kms.keytab</value>
  527. <description>
  528. The absolute path for the Kerberos keytab with the credentials to
  529. connect to Zookeeper.
  530. </description>
  531. </property>
  532. <property>
  533. <name>hadoop.kms.authentication.signer.secret.provider.zookeeper.kerberos.principal</name>
  534. <value>kms/#HOSTNAME#</value>
  535. <description>
  536. The Kerberos service principal used to connect to Zookeeper.
  537. </description>
  538. </property>
  539. ```
  540. $H4 Delegation Tokens
  541. TBD
  542. $H3 KMS HTTP REST API
  543. $H4 Create a Key
  544. *REQUEST:*
  545. POST http://HOST:PORT/kms/v1/keys
  546. Content-Type: application/json
  547. {
  548. "name" : "<key-name>",
  549. "cipher" : "<cipher>",
  550. "length" : <length>, //int
  551. "material" : "<material>", //base64
  552. "description" : "<description>"
  553. }
  554. *RESPONSE:*
  555. 201 CREATED
  556. LOCATION: http://HOST:PORT/kms/v1/key/<key-name>
  557. Content-Type: application/json
  558. {
  559. "name" : "versionName",
  560. "material" : "<material>", //base64, not present without GET ACL
  561. }
  562. $H4 Rollover Key
  563. *REQUEST:*
  564. POST http://HOST:PORT/kms/v1/key/<key-name>
  565. Content-Type: application/json
  566. {
  567. "material" : "<material>",
  568. }
  569. *RESPONSE:*
  570. 200 OK
  571. Content-Type: application/json
  572. {
  573. "name" : "versionName",
  574. "material" : "<material>", //base64, not present without GET ACL
  575. }
  576. $H4 Delete Key
  577. *REQUEST:*
  578. DELETE http://HOST:PORT/kms/v1/key/<key-name>
  579. *RESPONSE:*
  580. 200 OK
  581. $H4 Get Key Metadata
  582. *REQUEST:*
  583. GET http://HOST:PORT/kms/v1/key/<key-name>/_metadata
  584. *RESPONSE:*
  585. 200 OK
  586. Content-Type: application/json
  587. {
  588. "name" : "<key-name>",
  589. "cipher" : "<cipher>",
  590. "length" : <length>, //int
  591. "description" : "<description>",
  592. "created" : <millis-epoc>, //long
  593. "versions" : <versions> //int
  594. }
  595. $H4 Get Current Key
  596. *REQUEST:*
  597. GET http://HOST:PORT/kms/v1/key/<key-name>/_currentversion
  598. *RESPONSE:*
  599. 200 OK
  600. Content-Type: application/json
  601. {
  602. "name" : "versionName",
  603. "material" : "<material>", //base64
  604. }
  605. $H4 Generate Encrypted Key for Current KeyVersion
  606. *REQUEST:*
  607. GET http://HOST:PORT/kms/v1/key/<key-name>/_eek?eek_op=generate&num_keys=<number-of-keys-to-generate>
  608. *RESPONSE:*
  609. 200 OK
  610. Content-Type: application/json
  611. [
  612. {
  613. "versionName" : "encryptionVersionName",
  614. "iv" : "<iv>", //base64
  615. "encryptedKeyVersion" : {
  616. "versionName" : "EEK",
  617. "material" : "<material>", //base64
  618. }
  619. },
  620. {
  621. "versionName" : "encryptionVersionName",
  622. "iv" : "<iv>", //base64
  623. "encryptedKeyVersion" : {
  624. "versionName" : "EEK",
  625. "material" : "<material>", //base64
  626. }
  627. },
  628. ...
  629. ]
  630. $H4 Decrypt Encrypted Key
  631. *REQUEST:*
  632. POST http://HOST:PORT/kms/v1/keyversion/<version-name>/_eek?ee_op=decrypt
  633. Content-Type: application/json
  634. {
  635. "name" : "<key-name>",
  636. "iv" : "<iv>", //base64
  637. "material" : "<material>", //base64
  638. }
  639. *RESPONSE:*
  640. 200 OK
  641. Content-Type: application/json
  642. {
  643. "name" : "EK",
  644. "material" : "<material>", //base64
  645. }
  646. $H4 Get Key Version
  647. *REQUEST:*
  648. GET http://HOST:PORT/kms/v1/keyversion/<version-name>
  649. *RESPONSE:*
  650. 200 OK
  651. Content-Type: application/json
  652. {
  653. "name" : "versionName",
  654. "material" : "<material>", //base64
  655. }
  656. $H4 Get Key Versions
  657. *REQUEST:*
  658. GET http://HOST:PORT/kms/v1/key/<key-name>/_versions
  659. *RESPONSE:*
  660. 200 OK
  661. Content-Type: application/json
  662. [
  663. {
  664. "name" : "versionName",
  665. "material" : "<material>", //base64
  666. },
  667. {
  668. "name" : "versionName",
  669. "material" : "<material>", //base64
  670. },
  671. ...
  672. ]
  673. $H4 Get Key Names
  674. *REQUEST:*
  675. GET http://HOST:PORT/kms/v1/keys/names
  676. *RESPONSE:*
  677. 200 OK
  678. Content-Type: application/json
  679. [
  680. "<key-name>",
  681. "<key-name>",
  682. ...
  683. ]
  684. $H4 Get Keys Metadata
  685. GET http://HOST:PORT/kms/v1/keys/metadata?key=<key-name>&key=<key-name>,...
  686. *RESPONSE:*
  687. 200 OK
  688. Content-Type: application/json
  689. [
  690. {
  691. "name" : "<key-name>",
  692. "cipher" : "<cipher>",
  693. "length" : <length>, //int
  694. "description" : "<description>",
  695. "created" : <millis-epoc>, //long
  696. "versions" : <versions> //int
  697. },
  698. {
  699. "name" : "<key-name>",
  700. "cipher" : "<cipher>",
  701. "length" : <length>, //int
  702. "description" : "<description>",
  703. "created" : <millis-epoc>, //long
  704. "versions" : <versions> //int
  705. },
  706. ...
  707. ]