index.md.vm 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189
  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. <!-- MACRO{toc|fromDepth=0|toDepth=3} -->
  18. Hadoop KMS is a cryptographic key management server based on Hadoop's **KeyProvider** API.
  19. It provides a client and a server components which communicate over HTTP using a REST API.
  20. The client is a KeyProvider implementation interacts with the KMS using the KMS HTTP REST API.
  21. KMS and its client have built-in security and they support HTTP SPNEGO Kerberos authentication and HTTPS secure transport.
  22. KMS is a Java Jetty web-application.
  23. KMS Client Configuration
  24. ------------------------
  25. 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:9600/kms`, the KeyProvider URI is `kms://http@localhost:9600/kms`. And, for a KMS running on `https://localhost:9600/kms`, the KeyProvider URI is `kms://https@localhost:9600/kms`
  26. The following is an example to configure HDFS NameNode as a KMS client in
  27. `core-site.xml`:
  28. <property>
  29. <name>hadoop.security.key.provider.path</name>
  30. <value>kms://http@localhost:9600/kms</value>
  31. <description>
  32. The KeyProvider to use when interacting with encryption keys used
  33. when reading and writing to an encryption zone.
  34. </description>
  35. </property>
  36. KMS
  37. ---
  38. $H3 Start/Stop the KMS
  39. To start/stop KMS, use `hadoop --daemon start|stop kms`. For example:
  40. hadoop-${project.version} $ hadoop --daemon start kms
  41. NOTE: The script `kms.sh` is deprecated. It is now just a wrapper of
  42. `hadoop kms`.
  43. $H3 KMS Configuration
  44. Configure the KMS backing KeyProvider properties in the `etc/hadoop/kms-site.xml` configuration file:
  45. ```xml
  46. <property>
  47. <name>hadoop.kms.key.provider.uri</name>
  48. <value>jceks://file@/${user.home}/kms.keystore</value>
  49. </property>
  50. <property>
  51. <name>hadoop.security.keystore.java-keystore-provider.password-file</name>
  52. <value>kms.keystore.password</value>
  53. </property>
  54. ```
  55. The password file is looked up in the Hadoop's configuration directory via the classpath.
  56. NOTE: You need to restart the KMS for the configuration changes to take effect.
  57. NOTE: The KMS server can choose any `KeyProvider` implementation as the backing provider. The example here uses a JavaKeyStoreProvider, which should only be used for experimental purposes and never be used in production. For detailed usage and caveats of JavaKeyStoreProvider, please see [Keystore Passwords section of the Credential Provider API](../hadoop-project-dist/hadoop-common/CredentialProviderAPI.html#Keystore_Passwords).
  58. $H3 KMS HTTP Configuration
  59. KMS pre-configures the HTTP port to 9600.
  60. KMS supports the following HTTP [configuration properties](./kms-default.html)
  61. in `etc/hadoop/kms-site.xml`.
  62. NOTE: You need to restart the KMS for the configuration changes to take effect.
  63. $H3 KMS Cache
  64. KMS has two kinds of caching: a CachingKeyProvider for caching the encryption keys, and a KeyProvider for caching the EEKs.
  65. $H4 CachingKeyProvider
  66. KMS caches encryption keys for a short period of time to avoid excessive hits to the underlying KeyProvider.
  67. This Cache is enabled by default (can be disabled by setting the `hadoop.kms.cache.enable` boolean property to false)
  68. This cache is used with the following 3 methods only, `getCurrentKey()` and `getKeyVersion()` and `getMetadata()`.
  69. 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).
  70. For the `getKeyVersion()` and `getMetadata()` methods, cached entries are kept with a default inactivity timeout of 600000 milliseconds (10 mins).
  71. The cache is invalidated when the key is deleted by `deleteKey()`, or when `invalidateCache()` is called.
  72. These configurations can be changed via the following properties in the `etc/hadoop/kms-site.xml` configuration file:
  73. ```xml
  74. <property>
  75. <name>hadoop.kms.cache.enable</name>
  76. <value>true</value>
  77. </property>
  78. <property>
  79. <name>hadoop.kms.cache.timeout.ms</name>
  80. <value>600000</value>
  81. </property>
  82. <property>
  83. <name>hadoop.kms.current.key.cache.timeout.ms</name>
  84. <value>30000</value>
  85. </property>
  86. ```
  87. $H4 KeyProvider
  88. 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:
  89. * The size of the cache. This is the maximum number of EEKs that can be cached under each key name.
  90. * 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.
  91. * The maximum number of asynchronous threads overall, across key names, allowed to fill the queue in a cache.
  92. * 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).
  93. 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.
  94. Below are the configurations and their default values:
  95. Server-side can be changed via the following properties in the `etc/hadoop/kms-site.xml` configuration file:
  96. ```xml
  97. <property>
  98. <name>hadoop.security.kms.encrypted.key.cache.size</name>
  99. <value>500</value>
  100. </property>
  101. <property>
  102. <name>hadoop.security.kms.encrypted.key.cache.low.watermark</name>
  103. <value>0.3</value>
  104. </property>
  105. <property>
  106. <name>hadoop.security.kms.encrypted.key.cache.num.fill.threads</name>
  107. <value>2</value>
  108. </property>
  109. <property>
  110. <name>hadoop.security.kms.encrypted.key.cache.expiry</name>
  111. <value>43200000</value>
  112. </property>
  113. ```
  114. Client-side can be changed via the following properties in the `etc/hadoop/core-site.xml` configuration file:
  115. ```xml
  116. <property>
  117. <name>hadoop.security.kms.client.encrypted.key.cache.size</name>
  118. <value>500</value>
  119. </property>
  120. <property>
  121. <name>hadoop.security.kms.client.encrypted.key.cache.low-watermark</name>
  122. <value>0.3</value>
  123. </property>
  124. <property>
  125. <name>hadoop.security.kms.client.encrypted.key.cache.num.refill.threads</name>
  126. <value>2</value>
  127. </property>
  128. <property>
  129. <name>hadoop.security.kms.client.encrypted.key.cache.expiry</name>
  130. <value>43200000</value>
  131. </property>
  132. ```
  133. $H3 KMS Aggregated Audit logs
  134. Audit logs are aggregated for API accesses to the GET\_KEY\_VERSION, GET\_CURRENT\_KEY, DECRYPT\_EEK, GENERATE\_EEK, REENCRYPT\_EEK operations.
  135. 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.
  136. The Aggregation interval is configured via the property :
  137. <property>
  138. <name>hadoop.kms.aggregation.delay.ms</name>
  139. <value>10000</value>
  140. </property>
  141. $H3 KMS Security Configuration
  142. $H4 Enabling Kerberos HTTP SPNEGO Authentication
  143. Configure the Kerberos `etc/krb5.conf` file with the information of your KDC server.
  144. Create a service principal and its keytab for the KMS, it must be an `HTTP` service principal.
  145. Configure KMS `etc/hadoop/kms-site.xml` with the correct security values, for example:
  146. ```xml
  147. <property>
  148. <name>hadoop.kms.authentication.type</name>
  149. <value>kerberos</value>
  150. </property>
  151. <property>
  152. <name>hadoop.kms.authentication.kerberos.keytab</name>
  153. <value>${user.home}/kms.keytab</value>
  154. </property>
  155. <property>
  156. <name>hadoop.kms.authentication.kerberos.principal</name>
  157. <value>HTTP/localhost</value>
  158. </property>
  159. <property>
  160. <name>hadoop.kms.authentication.kerberos.name.rules</name>
  161. <value>DEFAULT</value>
  162. </property>
  163. ```
  164. NOTE: You need to restart the KMS for the configuration changes to take effect.
  165. $H4 KMS Proxyuser Configuration
  166. Each proxyuser must be configured in `etc/hadoop/kms-site.xml` using the following properties:
  167. ```xml
  168. <property>
  169. <name>hadoop.kms.proxyuser.#USER#.users</name>
  170. <value>*</value>
  171. </property>
  172. <property>
  173. <name>hadoop.kms.proxyuser.#USER#.groups</name>
  174. <value>*</value>
  175. </property>
  176. <property>
  177. <name>hadoop.kms.proxyuser.#USER#.hosts</name>
  178. <value>*</value>
  179. </property>
  180. ```
  181. `#USER#` is the username of the proxyuser to configure.
  182. The `users` property indicates the users that can be impersonated.
  183. The `groups` property indicates the groups users being impersonated must belong to.
  184. 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.
  185. The `hosts` property indicates from which host the proxyuser can make impersonation requests.
  186. If `users`, `groups` or `hosts` has a `*`, it means there are no restrictions for the proxyuser regarding users, groups or hosts.
  187. $H4 KMS over HTTPS (SSL)
  188. Enable SSL in `etc/hadoop/kms-site.xml`:
  189. ```xml
  190. <property>
  191. <name>hadoop.kms.ssl.enabled</name>
  192. <value>true</value>
  193. <description>
  194. Whether SSL is enabled. Default is false, i.e. disabled.
  195. </description>
  196. </property>
  197. ```
  198. Configure `etc/hadoop/ssl-server.xml` with proper values, for example:
  199. ```xml
  200. <property>
  201. <name>ssl.server.keystore.location</name>
  202. <value>${user.home}/.keystore</value>
  203. <description>Keystore to be used. Must be specified.</description>
  204. </property>
  205. <property>
  206. <name>ssl.server.keystore.password</name>
  207. <value></value>
  208. <description>Must be specified.</description>
  209. </property>
  210. <property>
  211. <name>ssl.server.keystore.keypassword</name>
  212. <value></value>
  213. <description>Must be specified.</description>
  214. </property>
  215. ```
  216. The SSL passwords can be secured by a credential provider. See
  217. [Credential Provider API](../hadoop-project-dist/hadoop-common/CredentialProviderAPI.html).
  218. 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:
  219. $ keytool -genkey -alias jetty -keyalg RSA
  220. You will be asked a series of questions in an interactive prompt. It will
  221. create the keystore file, which will be named **.keystore** and located in the
  222. user's home directory.
  223. The password you enter for "keystore password" must match the value of the
  224. property `ssl.server.keystore.password` set in the `ssl-server.xml` in the
  225. configuration directory.
  226. 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.
  227. NOTE: You need to restart the KMS for the configuration changes to take effect.
  228. NOTE: Some old SSL clients may use weak ciphers that are not supported by the KMS server. It is recommended to upgrade the SSL client.
  229. $H4 ACLs (Access Control Lists)
  230. KMS supports ACLs (Access Control Lists) for fine-grained permission control.
  231. Two levels of ACLs exist in KMS: KMS ACLs and Key ACLs. KMS ACLs control access at KMS operation level, and precede Key ACLs. In particular, only if permission is granted at KMS ACLs level, shall the permission check against Key ACLs be performed.
  232. The configuration and usage of KMS ACLs and Key ACLs are described in the sections below.
  233. $H5 KMS ACLs
  234. KMS ACLs configuration are defined in the KMS `etc/hadoop/kms-acls.xml` configuration file. This file is hot-reloaded when it changes.
  235. KMS supports both fine grained access control as well as blacklist for kms operations via a set ACL configuration properties.
  236. 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.
  237. ```xml
  238. <configuration>
  239. <property>
  240. <name>hadoop.kms.acl.CREATE</name>
  241. <value>*</value>
  242. <description>
  243. ACL for create-key operations.
  244. If the user is not in the GET ACL, the key material is not returned
  245. as part of the response.
  246. </description>
  247. </property>
  248. <property>
  249. <name>hadoop.kms.blacklist.CREATE</name>
  250. <value>hdfs,foo</value>
  251. <description>
  252. Blacklist for create-key operations.
  253. If the user is in the Blacklist, the key material is not returned
  254. as part of the response.
  255. </description>
  256. </property>
  257. <property>
  258. <name>hadoop.kms.acl.DELETE</name>
  259. <value>*</value>
  260. <description>
  261. ACL for delete-key operations.
  262. </description>
  263. </property>
  264. <property>
  265. <name>hadoop.kms.blacklist.DELETE</name>
  266. <value>hdfs,foo</value>
  267. <description>
  268. Blacklist for delete-key operations.
  269. </description>
  270. </property>
  271. <property>
  272. <name>hadoop.kms.acl.ROLLOVER</name>
  273. <value>*</value>
  274. <description>
  275. ACL for rollover-key operations.
  276. If the user is not in the GET ACL, the key material is not returned
  277. as part of the response.
  278. </description>
  279. </property>
  280. <property>
  281. <name>hadoop.kms.blacklist.ROLLOVER</name>
  282. <value>hdfs,foo</value>
  283. <description>
  284. Blacklist for rollover-key operations.
  285. </description>
  286. </property>
  287. <property>
  288. <name>hadoop.kms.acl.GET</name>
  289. <value>*</value>
  290. <description>
  291. ACL for get-key-version and get-current-key operations.
  292. </description>
  293. </property>
  294. <property>
  295. <name>hadoop.kms.blacklist.GET</name>
  296. <value>hdfs,foo</value>
  297. <description>
  298. ACL for get-key-version and get-current-key operations.
  299. </description>
  300. </property>
  301. <property>
  302. <name>hadoop.kms.acl.GET_KEYS</name>
  303. <value>*</value>
  304. <description>
  305. ACL for get-keys operation.
  306. </description>
  307. </property>
  308. <property>
  309. <name>hadoop.kms.blacklist.GET_KEYS</name>
  310. <value>hdfs,foo</value>
  311. <description>
  312. Blacklist for get-keys operation.
  313. </description>
  314. </property>
  315. <property>
  316. <name>hadoop.kms.acl.GET_METADATA</name>
  317. <value>*</value>
  318. <description>
  319. ACL for get-key-metadata and get-keys-metadata operations.
  320. </description>
  321. </property>
  322. <property>
  323. <name>hadoop.kms.blacklist.GET_METADATA</name>
  324. <value>hdfs,foo</value>
  325. <description>
  326. Blacklist for get-key-metadata and get-keys-metadata operations.
  327. </description>
  328. </property>
  329. <property>
  330. <name>hadoop.kms.acl.SET_KEY_MATERIAL</name>
  331. <value>*</value>
  332. <description>
  333. Complimentary ACL for CREATE and ROLLOVER operation to allow the client
  334. to provide the key material when creating or rolling a key.
  335. </description>
  336. </property>
  337. <property>
  338. <name>hadoop.kms.blacklist.SET_KEY_MATERIAL</name>
  339. <value>hdfs,foo</value>
  340. <description>
  341. Complimentary Blacklist for CREATE and ROLLOVER operation to allow the client
  342. to provide the key material when creating or rolling a key.
  343. </description>
  344. </property>
  345. <property>
  346. <name>hadoop.kms.acl.GENERATE_EEK</name>
  347. <value>*</value>
  348. <description>
  349. ACL for generateEncryptedKey
  350. CryptoExtension operations
  351. </description>
  352. </property>
  353. <property>
  354. <name>hadoop.kms.blacklist.GENERATE_EEK</name>
  355. <value>hdfs,foo</value>
  356. <description>
  357. Blacklist for generateEncryptedKey
  358. CryptoExtension operations
  359. </description>
  360. </property>
  361. <property>
  362. <name>hadoop.kms.acl.DECRYPT_EEK</name>
  363. <value>*</value>
  364. <description>
  365. ACL for decrypt EncryptedKey
  366. CryptoExtension operations
  367. </description>
  368. </property>
  369. <property>
  370. <name>hadoop.kms.blacklist.DECRYPT_EEK</name>
  371. <value>hdfs,foo</value>
  372. <description>
  373. Blacklist for decrypt EncryptedKey
  374. CryptoExtension operations
  375. </description>
  376. </property>
  377. </configuration>
  378. ```
  379. $H5 Key ACLs
  380. KMS supports access control for all non-read operations at the Key level. All Key Access operations are classified as :
  381. * MANAGEMENT - createKey, deleteKey, rolloverNewVersion
  382. * GENERATE_EEK - generateEncryptedKey, reencryptEncryptedKey, reencryptEncryptedKeys, warmUpEncryptedKeys
  383. * DECRYPT_EEK - decryptEncryptedKey
  384. * READ - getKeyVersion, getKeyVersions, getMetadata, getKeysMetadata, getCurrentKey
  385. * ALL - all of the above
  386. These can be defined in the KMS `etc/hadoop/kms-acls.xml` as follows
  387. 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.
  388. It is also possible to configure a "whitelist" key ACL for a subset of the operation types. The whitelist key ACL grants access to the key, 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.
  389. If no ACL is configured for a specific key AND no default ACL is configured AND no whitelist key ACL is configured for the requested operation, then access will be DENIED.
  390. **NOTE:** The default and whitelist key ACL does not support `ALL` operation qualifier.
  391. ```xml
  392. <property>
  393. <name>key.acl.testKey1.MANAGEMENT</name>
  394. <value>*</value>
  395. <description>
  396. ACL for create-key, deleteKey and rolloverNewVersion operations.
  397. </description>
  398. </property>
  399. <property>
  400. <name>key.acl.testKey2.GENERATE_EEK</name>
  401. <value>*</value>
  402. <description>
  403. ACL for generateEncryptedKey operations.
  404. </description>
  405. </property>
  406. <property>
  407. <name>key.acl.testKey3.DECRYPT_EEK</name>
  408. <value>admink3</value>
  409. <description>
  410. ACL for decryptEncryptedKey operations.
  411. </description>
  412. </property>
  413. <property>
  414. <name>key.acl.testKey4.READ</name>
  415. <value>*</value>
  416. <description>
  417. ACL for getKeyVersion, getKeyVersions, getMetadata, getKeysMetadata,
  418. getCurrentKey operations
  419. </description>
  420. </property>
  421. <property>
  422. <name>key.acl.testKey5.ALL</name>
  423. <value>*</value>
  424. <description>
  425. ACL for ALL operations.
  426. </description>
  427. </property>
  428. <property>
  429. <name>whitelist.key.acl.MANAGEMENT</name>
  430. <value>admin1</value>
  431. <description>
  432. whitelist ACL for MANAGEMENT operations for all keys.
  433. </description>
  434. </property>
  435. <!--
  436. 'testKey3' key ACL is defined. Since a 'whitelist'
  437. key is also defined for DECRYPT_EEK, in addition to
  438. admink3, admin1 can also perform DECRYPT_EEK operations
  439. on 'testKey3'
  440. -->
  441. <property>
  442. <name>whitelist.key.acl.DECRYPT_EEK</name>
  443. <value>admin1</value>
  444. <description>
  445. whitelist ACL for DECRYPT_EEK operations for all keys.
  446. </description>
  447. </property>
  448. <property>
  449. <name>default.key.acl.MANAGEMENT</name>
  450. <value>user1,user2</value>
  451. <description>
  452. default ACL for MANAGEMENT operations for all keys that are not
  453. explicitly defined.
  454. </description>
  455. </property>
  456. <property>
  457. <name>default.key.acl.GENERATE_EEK</name>
  458. <value>user1,user2</value>
  459. <description>
  460. default ACL for GENERATE_EEK operations for all keys that are not
  461. explicitly defined.
  462. </description>
  463. </property>
  464. <property>
  465. <name>default.key.acl.DECRYPT_EEK</name>
  466. <value>user1,user2</value>
  467. <description>
  468. default ACL for DECRYPT_EEK operations for all keys that are not
  469. explicitly defined.
  470. </description>
  471. </property>
  472. <property>
  473. <name>default.key.acl.READ</name>
  474. <value>user1,user2</value>
  475. <description>
  476. default ACL for READ operations for all keys that are not
  477. explicitly defined.
  478. </description>
  479. </property>
  480. ```
  481. $H3 KMS Delegation Token Configuration
  482. KMS supports delegation tokens to authenticate to the key providers from processes without Kerberos credentials.
  483. KMS delegation token authentication extends the default Hadoop authentication. Same as Hadoop authentication, KMS delegation tokens must not be fetched or renewed using delegation token authentication. See [Hadoop Auth](../hadoop-auth/index.html) page for more details.
  484. Additionally, KMS delegation token secret manager can be configured with the following properties:
  485. ```xml
  486. <property>
  487. <name>hadoop.kms.authentication.delegation-token.update-interval.sec</name>
  488. <value>86400</value>
  489. <description>
  490. How often the master key is rotated, in seconds. Default value 1 day.
  491. </description>
  492. </property>
  493. <property>
  494. <name>hadoop.kms.authentication.delegation-token.max-lifetime.sec</name>
  495. <value>604800</value>
  496. <description>
  497. Maximum lifetime of a delegation token, in seconds. Default value 7 days.
  498. </description>
  499. </property>
  500. <property>
  501. <name>hadoop.kms.authentication.delegation-token.renew-interval.sec</name>
  502. <value>86400</value>
  503. <description>
  504. Renewal interval of a delegation token, in seconds. Default value 1 day.
  505. </description>
  506. </property>
  507. <property>
  508. <name>hadoop.kms.authentication.delegation-token.removal-scan-interval.sec</name>
  509. <value>3600</value>
  510. <description>
  511. Scan interval to remove expired delegation tokens.
  512. </description>
  513. </property>
  514. ```
  515. $H3 High Availability
  516. Multiple KMS instances may be used to provide high availability and scalability.
  517. Currently there are two approaches to supporting multiple KMS instances:
  518. running KMS instances behind a load-balancer/VIP,
  519. or using LoadBalancingKMSClientProvider.
  520. In both approaches, KMS instances must be specially configured to work properly
  521. as a single logical service, because requests from the same client may be
  522. handled by different KMS instances. In particular,
  523. Kerberos Principals Configuration, HTTP Authentication Signature and Delegation
  524. Tokens require special attention.
  525. $H4 Behind a Load-Balancer or VIP
  526. Because KMS clients and servers communicate via a REST API over HTTP,
  527. Load-balancer or VIP may be used to distribute incoming traffic to achieve
  528. scalability and HA. In this mode, clients are unaware of multiple KMS instances
  529. at the server-side.
  530. $H4 Using LoadBalancingKMSClientProvider
  531. An alternative to running multiple KMS instances behind a load-balancer or VIP,
  532. is to use LoadBalancingKMSClientProvider. Using this approach, a KMS client
  533. (for example, a HDFS NameNode) is aware of multiple KMS instances, and it sends
  534. requests to them in a round-robin fashion. LoadBalancingKMSClientProvider is
  535. implicitly used when more than one URI is specified in
  536. `hadoop.security.key.provider.path`.
  537. The following example in `core-site.xml` configures two KMS
  538. instances, `kms01.example.com` and `kms02.example.com`.
  539. The hostnames are separated by semi-colons, and all KMS instances must run
  540. on the same port.
  541. <property>
  542. <name>hadoop.security.key.provider.path</name>
  543. <value>kms://https@kms01.example.com;kms02.example.com:9600/kms</value>
  544. <description>
  545. The KeyProvider to use when interacting with encryption keys used
  546. when reading and writing to an encryption zone.
  547. </description>
  548. </property>
  549. If a request to a KMS instance fails, clients retry with the next instance. The
  550. request is returned as failure only if all instances fail.
  551. $H4 HTTP Kerberos Principals Configuration
  552. 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.
  553. In order to be able to access directly a specific KMS instance, the KMS instance must also have Kerberos service name with its own hostname. This is required for monitoring and admin purposes.
  554. 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:
  555. ```xml
  556. <property>
  557. <name>hadoop.kms.authentication.kerberos.principal</name>
  558. <value>*</value>
  559. </property>
  560. ```
  561. **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).
  562. $H4 HTTP Authentication Signature
  563. 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.
  564. 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. Please see [SignerSecretProvider Configuration](../hadoop-auth/Configuration.html#SignerSecretProvider_Configuration) for detailed description and configuration examples. Note that KMS configurations need to be prefixed with `hadoop.kms.authentication`, as shown in the example below.
  565. This secret sharing can be done using a Zookeeper service which is configured in KMS with the following properties in the `kms-site.xml`:
  566. ```xml
  567. <property>
  568. <name>hadoop.kms.authentication.signer.secret.provider</name>
  569. <value>zookeeper</value>
  570. <description>
  571. Indicates how the secret to sign the authentication cookies will be
  572. stored. Options are 'random' (default), 'file' and 'zookeeper'.
  573. If using a setup with multiple KMS instances, 'zookeeper' should be used.
  574. If using file, signature.secret.file should be configured and point to the secret file.
  575. </description>
  576. </property>
  577. <property>
  578. <name>hadoop.kms.authentication.signer.secret.provider.zookeeper.path</name>
  579. <value>/hadoop-kms/hadoop-auth-signature-secret</value>
  580. <description>
  581. The Zookeeper ZNode path where the KMS instances will store and retrieve
  582. the secret from. All KMS instances that need to coordinate should point to the same path.
  583. </description>
  584. </property>
  585. <property>
  586. <name>hadoop.kms.authentication.signer.secret.provider.zookeeper.connection.string</name>
  587. <value>#HOSTNAME#:#PORT#,...</value>
  588. <description>
  589. The Zookeeper connection string, a list of hostnames and port comma
  590. separated.
  591. </description>
  592. </property>
  593. <property>
  594. <name>hadoop.kms.authentication.signer.secret.provider.zookeeper.auth.type</name>
  595. <value>sasl</value>
  596. <description>
  597. The Zookeeper authentication type, 'none' (default) or 'sasl' (Kerberos).
  598. </description>
  599. </property>
  600. <property>
  601. <name>hadoop.kms.authentication.signer.secret.provider.zookeeper.kerberos.keytab</name>
  602. <value>/etc/hadoop/conf/kms.keytab</value>
  603. <description>
  604. The absolute path for the Kerberos keytab with the credentials to
  605. connect to Zookeeper.
  606. </description>
  607. </property>
  608. <property>
  609. <name>hadoop.kms.authentication.signer.secret.provider.zookeeper.kerberos.principal</name>
  610. <value>kms/#HOSTNAME#</value>
  611. <description>
  612. The Kerberos service principal used to connect to Zookeeper.
  613. </description>
  614. </property>
  615. ```
  616. $H4 Delegation Tokens
  617. Similar to HTTP authentication, KMS uses Hadoop Authentication for delegation tokens too.
  618. Under HA, A KMS instance must verify the delegation token given by another KMS instance, by checking the shared secret used to sign the delegation token. To do this, all KMS instances must be able to retrieve the shared secret from ZooKeeper.
  619. Please see the examples given in HTTP Authentication section to configure ZooKeeper for secret sharing.
  620. $H3 KMS HTTP REST API
  621. $H4 Create a Key
  622. *REQUEST:*
  623. POST http://HOST:PORT/kms/v1/keys
  624. Content-Type: application/json
  625. {
  626. "name" : "<key-name>",
  627. "cipher" : "<cipher>",
  628. "length" : <length>, //int
  629. "material" : "<material>", //base64
  630. "description" : "<description>"
  631. }
  632. *RESPONSE:*
  633. 201 CREATED
  634. LOCATION: http://HOST:PORT/kms/v1/key/<key-name>
  635. Content-Type: application/json
  636. {
  637. "name" : "versionName",
  638. "material" : "<material>", //base64, not present without GET ACL
  639. }
  640. $H4 Rollover Key
  641. *REQUEST:*
  642. POST http://HOST:PORT/kms/v1/key/<key-name>
  643. Content-Type: application/json
  644. {
  645. "material" : "<material>",
  646. }
  647. *RESPONSE:*
  648. 200 OK
  649. Content-Type: application/json
  650. {
  651. "name" : "versionName",
  652. "material" : "<material>", //base64, not present without GET ACL
  653. }
  654. $H4 Invalidate Cache of a Key
  655. *REQUEST:*
  656. POST http://HOST:PORT/kms/v1/key/<key-name>/_invalidatecache
  657. *RESPONSE:*
  658. 200 OK
  659. $H4 Delete Key
  660. *REQUEST:*
  661. DELETE http://HOST:PORT/kms/v1/key/<key-name>
  662. *RESPONSE:*
  663. 200 OK
  664. $H4 Get Key Metadata
  665. *REQUEST:*
  666. GET http://HOST:PORT/kms/v1/key/<key-name>/_metadata
  667. *RESPONSE:*
  668. 200 OK
  669. Content-Type: application/json
  670. {
  671. "name" : "<key-name>",
  672. "cipher" : "<cipher>",
  673. "length" : <length>, //int
  674. "description" : "<description>",
  675. "created" : <millis-epoc>, //long
  676. "versions" : <versions> //int
  677. }
  678. $H4 Get Current Key
  679. *REQUEST:*
  680. GET http://HOST:PORT/kms/v1/key/<key-name>/_currentversion
  681. *RESPONSE:*
  682. 200 OK
  683. Content-Type: application/json
  684. {
  685. "name" : "versionName",
  686. "material" : "<material>", //base64
  687. }
  688. $H4 Generate Encrypted Key for Current KeyVersion
  689. *REQUEST:*
  690. GET http://HOST:PORT/kms/v1/key/<key-name>/_eek?eek_op=generate&num_keys=<number-of-keys-to-generate>
  691. *RESPONSE:*
  692. 200 OK
  693. Content-Type: application/json
  694. [
  695. {
  696. "versionName" : "<encryptionVersionName>",
  697. "iv" : "<iv>", //base64
  698. "encryptedKeyVersion" : {
  699. "versionName" : "EEK",
  700. "material" : "<material>", //base64
  701. }
  702. },
  703. {
  704. "versionName" : "<encryptionVersionName>",
  705. "iv" : "<iv>", //base64
  706. "encryptedKeyVersion" : {
  707. "versionName" : "EEK",
  708. "material" : "<material>", //base64
  709. }
  710. },
  711. ...
  712. ]
  713. $H4 Decrypt Encrypted Key
  714. *REQUEST:*
  715. POST http://HOST:PORT/kms/v1/keyversion/<version-name>/_eek?eek_op=decrypt
  716. Content-Type: application/json
  717. {
  718. "name" : "<key-name>",
  719. "iv" : "<iv>", //base64
  720. "material" : "<material>", //base64
  721. }
  722. *RESPONSE:*
  723. 200 OK
  724. Content-Type: application/json
  725. {
  726. "name" : "EK",
  727. "material" : "<material>", //base64
  728. }
  729. $H4 Re-encrypt Encrypted Key With The Latest KeyVersion
  730. This command takes a previously generated encrypted key, and re-encrypts it using the latest KeyVersion encryption key in the KeyProvider. If the latest KeyVersion is the same as the one used to generate the encrypted key, the same encrypted key is returned.
  731. This is usually useful after a [Rollover](#Rollover_Key) of an encryption key. Re-encrypting the encrypted key will allow it to be encrypted using the latest version of the encryption key, but still with the same key material and initialization vector.
  732. *REQUEST:*
  733. POST http://HOST:PORT/kms/v1/keyversion/<version-name>/_eek?eek_op=reencrypt
  734. Content-Type: application/json
  735. {
  736. "name" : "<key-name>",
  737. "iv" : "<iv>", //base64
  738. "material" : "<material>", //base64
  739. }
  740. *RESPONSE:*
  741. 200 OK
  742. Content-Type: application/json
  743. {
  744. "versionName" : "<encryptionVersionName>",
  745. "iv" : "<iv>", //base64
  746. "encryptedKeyVersion" : {
  747. "versionName" : "EEK",
  748. "material" : "<material>", //base64
  749. }
  750. }
  751. $H4 Batch Re-encrypt Encrypted Keys With The Latest KeyVersion
  752. Batched version of the above re-encrypt Encrypted Key. This command takes a list of previously generated encrypted key, and re-encrypts them using the latest KeyVersion encryption key in the KeyProvider, and return the re-encrypted encrypted keys in the same sequence. For each encrypted key, if the latest KeyVersion is the same as the one used to generate the encrypted key, no action is taken and the same encrypted key is returned.
  753. This is usually useful after a [Rollover](#Rollover_Key) of an encryption key. Re-encrypting the encrypted key will allow it to be encrypted using the latest version of the encryption key, but still with the same key material and initialization vector.
  754. All Encrypted keys for a batch request must be under the same encryption key name, but could be potentially under different versions of the encryption key.
  755. *REQUEST:*
  756. POST http://HOST:PORT/kms/v1/key/<key-name>/_reencryptbatch
  757. Content-Type: application/json
  758. [
  759. {
  760. "versionName" : "<encryptionVersionName>",
  761. "iv" : "<iv>", //base64
  762. "encryptedKeyVersion" : {
  763. "versionName" : "EEK",
  764. "material" : "<material>", //base64
  765. }
  766. },
  767. {
  768. "versionName" : "<encryptionVersionName>",
  769. "iv" : "<iv>", //base64
  770. "encryptedKeyVersion" : {
  771. "versionName" : "EEK",
  772. "material" : "<material>", //base64
  773. }
  774. },
  775. ...
  776. ]
  777. *RESPONSE:*
  778. 200 OK
  779. Content-Type: application/json
  780. [
  781. {
  782. "versionName" : "<encryptionVersionName>",
  783. "iv" : "<iv>", //base64
  784. "encryptedKeyVersion" : {
  785. "versionName" : "EEK",
  786. "material" : "<material>", //base64
  787. }
  788. },
  789. {
  790. "versionName" : "<encryptionVersionName>",
  791. "iv" : "<iv>", //base64
  792. "encryptedKeyVersion" : {
  793. "versionName" : "EEK",
  794. "material" : "<material>", //base64
  795. }
  796. },
  797. ...
  798. ]
  799. $H4 Get Key Version
  800. *REQUEST:*
  801. GET http://HOST:PORT/kms/v1/keyversion/<version-name>
  802. *RESPONSE:*
  803. 200 OK
  804. Content-Type: application/json
  805. {
  806. "name" : "versionName",
  807. "material" : "<material>", //base64
  808. }
  809. $H4 Get Key Versions
  810. *REQUEST:*
  811. GET http://HOST:PORT/kms/v1/key/<key-name>/_versions
  812. *RESPONSE:*
  813. 200 OK
  814. Content-Type: application/json
  815. [
  816. {
  817. "name" : "versionName",
  818. "material" : "<material>", //base64
  819. },
  820. {
  821. "name" : "versionName",
  822. "material" : "<material>", //base64
  823. },
  824. ...
  825. ]
  826. $H4 Get Key Names
  827. *REQUEST:*
  828. GET http://HOST:PORT/kms/v1/keys/names
  829. *RESPONSE:*
  830. 200 OK
  831. Content-Type: application/json
  832. [
  833. "<key-name>",
  834. "<key-name>",
  835. ...
  836. ]
  837. $H4 Get Keys Metadata
  838. GET http://HOST:PORT/kms/v1/keys/metadata?key=<key-name>&key=<key-name>,...
  839. *RESPONSE:*
  840. 200 OK
  841. Content-Type: application/json
  842. [
  843. {
  844. "name" : "<key-name>",
  845. "cipher" : "<cipher>",
  846. "length" : <length>, //int
  847. "description" : "<description>",
  848. "created" : <millis-epoc>, //long
  849. "versions" : <versions> //int
  850. },
  851. {
  852. "name" : "<key-name>",
  853. "cipher" : "<cipher>",
  854. "length" : <length>, //int
  855. "description" : "<description>",
  856. "created" : <millis-epoc>, //long
  857. "versions" : <versions> //int
  858. },
  859. ...
  860. ]
  861. $H3 Deprecated Environment Variables
  862. The following environment variables are deprecated. Set the corresponding
  863. configuration properties instead.
  864. Environment Variable | Configuration Property | Configuration File
  865. -------------------------|------------------------------|--------------------
  866. KMS_TEMP | hadoop.http.temp.dir | kms-site.xml
  867. KMS_HTTP_PORT | hadoop.kms.http.port | kms-site.xml
  868. KMS_MAX_HTTP_HEADER_SIZE | hadoop.http.max.request.header.size and hadoop.http.max.response.header.size | kms-site.xml
  869. KMS_MAX_THREADS | hadoop.http.max.threads | kms-site.xml
  870. KMS_SSL_ENABLED | hadoop.kms.ssl.enabled | kms-site.xml
  871. KMS_SSL_KEYSTORE_FILE | ssl.server.keystore.location | ssl-server.xml
  872. KMS_SSL_KEYSTORE_PASS | ssl.server.keystore.password | ssl-server.xml
  873. $H3 Default HTTP Services
  874. Name | Description
  875. -------------------|------------------------------------
  876. /conf | Display configuration properties
  877. /jmx | Java JMX management interface
  878. /logLevel | Get or set log level per class
  879. /logs | Display log files
  880. /stacks | Display JVM stacks
  881. /static/index.html | The static home page
  882. To control the access to servlet `/conf`, `/jmx`, `/logLevel`, `/logs`,
  883. and `/stacks`, configure the following properties in `kms-site.xml`:
  884. ```xml
  885. <property>
  886. <name>hadoop.security.authorization</name>
  887. <value>true</value>
  888. <description>Is service-level authorization enabled?</description>
  889. </property>
  890. <property>
  891. <name>hadoop.security.instrumentation.requires.admin</name>
  892. <value>true</value>
  893. <description>
  894. Indicates if administrator ACLs are required to access
  895. instrumentation servlets (JMX, METRICS, CONF, STACKS).
  896. </description>
  897. </property>
  898. <property>
  899. <name>hadoop.kms.http.administrators</name>
  900. <value></value>
  901. <description>ACL for the admins, this configuration is used to control
  902. who can access the default KMS servlets. The value should be a comma
  903. separated list of users and groups. The user list comes first and is
  904. separated by a space followed by the group list,
  905. e.g. "user1,user2 group1,group2". Both users and groups are optional,
  906. so "user1", " group1", "", "user1 group1", "user1,user2 group1,group2"
  907. are all valid (note the leading space in " group1"). '*' grants access
  908. to all users and groups, e.g. '*', '* ' and ' *' are all valid.
  909. </description>
  910. </property>
  911. ```