index.apt.vm 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  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. ** Start/Stop the KMS
  82. To start/stop KMS use KMS's bin/kms.sh script. For example:
  83. +---+
  84. hadoop-${project.version} $ sbin/kms.sh start
  85. +---+
  86. NOTE: Invoking the script without any parameters list all possible
  87. parameters (start, stop, run, etc.). The <<<kms.sh>>> script is a wrapper
  88. for Tomcat's <<<catalina.sh>>> script that sets the environment variables
  89. and Java System properties required to run KMS.
  90. ** Embedded Tomcat Configuration
  91. To configure the embedded Tomcat go to the <<<share/hadoop/kms/tomcat/conf>>>.
  92. KMS pre-configures the HTTP and Admin ports in Tomcat's <<<server.xml>>> to
  93. 16000 and 16001.
  94. Tomcat logs are also preconfigured to go to Hadoop's <<<logs/>>> directory.
  95. The following environment variables (which can be set in KMS's
  96. <<<etc/hadoop/kms-env.sh>>> script) can be used to alter those values:
  97. * KMS_HTTP_PORT
  98. * KMS_ADMIN_PORT
  99. * KMS_LOG
  100. NOTE: You need to restart the KMS for the configuration changes to take
  101. effect.
  102. ** KMS Security Configuration
  103. *** Enabling Kerberos HTTP SPNEGO Authentication
  104. Configure the Kerberos <<<etc/krb5.conf>>> file with the information of your
  105. KDC server.
  106. Create a service principal and its keytab for the KMS, it must be an
  107. <<<HTTP>>> service principal.
  108. Configure KMS <<<etc/hadoop/kms-site.xml>>> with the correct security values,
  109. for example:
  110. +---+
  111. <property>
  112. <name>hadoop.kms.authentication.type</name>
  113. <value>kerberos</value>
  114. </property>
  115. <property>
  116. <name>hadoop.kms.authentication.kerberos.keytab</name>
  117. <value>${user.home}/kms.keytab</value>
  118. </property>
  119. <property>
  120. <name>hadoop.kms.authentication.kerberos.principal</name>
  121. <value>HTTP/localhost</value>
  122. </property>
  123. <property>
  124. <name>hadoop.kms.authentication.kerberos.name.rules</name>
  125. <value>DEFAULT</value>
  126. </property>
  127. +---+
  128. NOTE: You need to restart the KMS for the configuration changes to take
  129. effect.
  130. *** KMS over HTTPS (SSL)
  131. To configure KMS to work over HTTPS the following 2 properties must be
  132. set in the <<<etc/hadoop/kms_env.sh>>> script (shown with default values):
  133. * KMS_SSL_KEYSTORE_FILE=${HOME}/.keystore
  134. * KMS_SSL_KEYSTORE_PASS=password
  135. In the KMS <<<tomcat/conf>>> directory, replace the <<<server.xml>>> file
  136. with the provided <<<ssl-server.xml>>> file.
  137. You need to create an SSL certificate for the KMS. As the
  138. <<<kms>>> Unix user, using the Java <<<keytool>>> command to create the
  139. SSL certificate:
  140. +---+
  141. $ keytool -genkey -alias tomcat -keyalg RSA
  142. +---+
  143. You will be asked a series of questions in an interactive prompt. It will
  144. create the keystore file, which will be named <<.keystore>> and located in the
  145. <<<kms>>> user home directory.
  146. The password you enter for "keystore password" must match the value of the
  147. <<<KMS_SSL_KEYSTORE_PASS>>> environment variable set in the
  148. <<<kms-env.sh>>> script in the configuration directory.
  149. The answer to "What is your first and last name?" (i.e. "CN") must be the
  150. hostname of the machine where the KMS will be running.
  151. NOTE: You need to restart the KMS for the configuration changes to take
  152. effect.
  153. *** KMS Access Control
  154. KMS ACLs configuration are defined in the KMS <<<etc/hadoop/kms-acls.xml>>>
  155. configuration file. This file is hot-reloaded when it changes.
  156. KMS supports a fine grained access control via a set ACL
  157. configuration properties:
  158. +---+
  159. <property>
  160. <name>hadoop.kms.acl.CREATE</name>
  161. <value>*</value>
  162. <description>
  163. ACL for create-key operations.
  164. If the user does is not in the GET ACL, the key material is not returned
  165. as part of the response.
  166. </description>
  167. </property>
  168. <property>
  169. <name>hadoop.kms.acl.DELETE</name>
  170. <value>*</value>
  171. <description>
  172. ACL for delete-key operations.
  173. </description>
  174. </property>
  175. <property>
  176. <name>hadoop.kms.acl.ROLLOVER</name>
  177. <value>*</value>
  178. <description>
  179. ACL for rollover-key operations.
  180. If the user does is not in the GET ACL, the key material is not returned
  181. as part of the response.
  182. </description>
  183. </property>
  184. <property>
  185. <name>hadoop.kms.acl.GET</name>
  186. <value>*</value>
  187. <description>
  188. ACL for get-key-version and get-current-key operations.
  189. </description>
  190. </property>
  191. <property>
  192. <name>hadoop.kms.acl.GET_KEYS</name>
  193. <value>*</value>
  194. <description>
  195. ACL for get-keys operation.
  196. </description>
  197. </property>
  198. <property>
  199. <name>hadoop.kms.acl.GET_METADATA</name>
  200. <value>*</value>
  201. <description>
  202. ACL for get-key-metadata and get-keys-metadata operations.
  203. </description>
  204. </property>
  205. <property>
  206. <name>hadoop.kms.acl.SET_KEY_MATERIAL</name>
  207. <value>*</value>
  208. <description>
  209. Complimentary ACL for CREATE and ROLLOVER operation to allow the client
  210. to provide the key material when creating or rolling a key.
  211. </description>
  212. </property>
  213. <property>
  214. <name>hadoop.kms.acl.GENERATE_EEK</name>
  215. <value>*</value>
  216. <description>
  217. ACL for generateEncryptedKey
  218. CryptoExtension operations
  219. </description>
  220. </property>
  221. <property>
  222. <name>hadoop.kms.acl.DECRYPT_EEK</name>
  223. <value>*</value>
  224. <description>
  225. ACL for decrypt EncryptedKey
  226. CryptoExtension operations
  227. </description>
  228. </property>
  229. </configuration>
  230. +---+
  231. ** KMS HTTP REST API
  232. *** Create a Key
  233. <REQUEST:>
  234. +---+
  235. POST http://HOST:PORT/kms/v1/keys
  236. Content-Type: application/json
  237. {
  238. "name" : "<key-name>",
  239. "cipher" : "<cipher>",
  240. "length" : <length>, //int
  241. "material" : "<material>", //base64
  242. "description" : "<description>"
  243. }
  244. +---+
  245. <RESPONSE:>
  246. +---+
  247. 201 CREATED
  248. LOCATION: http://HOST:PORT/kms/v1/key/<key-name>
  249. Content-Type: application/json
  250. {
  251. "name" : "versionName",
  252. "material" : "<material>", //base64, not present without GET ACL
  253. }
  254. +---+
  255. *** Rollover Key
  256. <REQUEST:>
  257. +---+
  258. POST http://HOST:PORT/kms/v1/key/<key-name>
  259. Content-Type: application/json
  260. {
  261. "material" : "<material>",
  262. }
  263. +---+
  264. <RESPONSE:>
  265. +---+
  266. 200 OK
  267. Content-Type: application/json
  268. {
  269. "name" : "versionName",
  270. "material" : "<material>", //base64, not present without GET ACL
  271. }
  272. +---+
  273. *** Delete Key
  274. <REQUEST:>
  275. +---+
  276. DELETE http://HOST:PORT/kms/v1/key/<key-name>
  277. +---+
  278. <RESPONSE:>
  279. +---+
  280. 200 OK
  281. +---+
  282. *** Get Key Metadata
  283. <REQUEST:>
  284. +---+
  285. GET http://HOST:PORT/kms/v1/key/<key-name>/_metadata
  286. +---+
  287. <RESPONSE:>
  288. +---+
  289. 200 OK
  290. Content-Type: application/json
  291. {
  292. "name" : "<key-name>",
  293. "cipher" : "<cipher>",
  294. "length" : <length>, //int
  295. "description" : "<description>",
  296. "created" : <millis-epoc>, //long
  297. "versions" : <versions> //int
  298. }
  299. +---+
  300. *** Get Current Key
  301. <REQUEST:>
  302. +---+
  303. GET http://HOST:PORT/kms/v1/key/<key-name>/_currentversion
  304. +---+
  305. <RESPONSE:>
  306. +---+
  307. 200 OK
  308. Content-Type: application/json
  309. {
  310. "name" : "versionName",
  311. "material" : "<material>", //base64
  312. }
  313. +---+
  314. *** Generate Encrypted Key for Current KeyVersion
  315. <REQUEST:>
  316. +---+
  317. GET http://HOST:PORT/kms/v1/key/<key-name>/_eek?eek_op=generate&num_keys=<number-of-keys-to-generate>
  318. +---+
  319. <RESPONSE:>
  320. +---+
  321. 200 OK
  322. Content-Type: application/json
  323. [
  324. {
  325. "versionName" : "encryptionVersionName",
  326. "iv" : "<iv>", //base64
  327. "encryptedKeyVersion" : {
  328. "versionName" : "EEK",
  329. "material" : "<material>", //base64
  330. }
  331. },
  332. {
  333. "versionName" : "encryptionVersionName",
  334. "iv" : "<iv>", //base64
  335. "encryptedKeyVersion" : {
  336. "versionName" : "EEK",
  337. "material" : "<material>", //base64
  338. }
  339. },
  340. ...
  341. ]
  342. +---+
  343. *** Decrypt Encrypted Key
  344. <REQUEST:>
  345. +---+
  346. POST http://HOST:PORT/kms/v1/keyversion/<version-name>/_eek?ee_op=decrypt
  347. Content-Type: application/json
  348. {
  349. "name" : "<key-name>",
  350. "iv" : "<iv>", //base64
  351. "material" : "<material>", //base64
  352. }
  353. +---+
  354. <RESPONSE:>
  355. +---+
  356. 200 OK
  357. Content-Type: application/json
  358. {
  359. "name" : "EK",
  360. "material" : "<material>", //base64
  361. }
  362. +---+
  363. *** Get Key Version
  364. <REQUEST:>
  365. +---+
  366. GET http://HOST:PORT/kms/v1/keyversion/<version-name>
  367. +---+
  368. <RESPONSE:>
  369. +---+
  370. 200 OK
  371. Content-Type: application/json
  372. {
  373. "name" : "versionName",
  374. "material" : "<material>", //base64
  375. }
  376. +---+
  377. *** Get Key Versions
  378. <REQUEST:>
  379. +---+
  380. GET http://HOST:PORT/kms/v1/key/<key-name>/_versions
  381. +---+
  382. <RESPONSE:>
  383. +---+
  384. 200 OK
  385. Content-Type: application/json
  386. [
  387. {
  388. "name" : "versionName",
  389. "material" : "<material>", //base64
  390. },
  391. {
  392. "name" : "versionName",
  393. "material" : "<material>", //base64
  394. },
  395. ...
  396. ]
  397. +---+
  398. *** Get Key Names
  399. <REQUEST:>
  400. +---+
  401. GET http://HOST:PORT/kms/v1/keys/names
  402. +---+
  403. <RESPONSE:>
  404. +---+
  405. 200 OK
  406. Content-Type: application/json
  407. [
  408. "<key-name>",
  409. "<key-name>",
  410. ...
  411. ]
  412. +---+
  413. *** Get Keys Metadata
  414. +---+
  415. GET http://HOST:PORT/kms/v1/keys/metadata?key=<key-name>&key=<key-name>,...
  416. +---+
  417. <RESPONSE:>
  418. +---+
  419. 200 OK
  420. Content-Type: application/json
  421. [
  422. {
  423. "name" : "<key-name>",
  424. "cipher" : "<cipher>",
  425. "length" : <length>, //int
  426. "description" : "<description>",
  427. "created" : <millis-epoc>, //long
  428. "versions" : <versions> //int
  429. },
  430. {
  431. "name" : "<key-name>",
  432. "cipher" : "<cipher>",
  433. "length" : <length>, //int
  434. "description" : "<description>",
  435. "created" : <millis-epoc>, //long
  436. "versions" : <versions> //int
  437. },
  438. ...
  439. ]
  440. +---+
  441. \[ {{{./index.html}Go Back}} \]