ImportKeyUtil: ImportKey.html

File ImportKey.html, 10.2 KB (added by jpmitchell@…, 13 years ago)
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<!--NewPage-->
3<HTML>
4<HEAD>
5<!-- Generated by javadoc (build 1.6.0_16) on Fri Jul 08 11:09:20 AKDT 2011 -->
6<TITLE>
7ImportKey
8</TITLE>
9
10<META NAME="date" CONTENT="2011-07-08">
11
12<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
13
14<SCRIPT type="text/javascript">
15function windowTitle()
16{
17    if (location.href.indexOf('is-external=true') == -1) {
18        parent.document.title="ImportKey";
19    }
20}
21</SCRIPT>
22<NOSCRIPT>
23</NOSCRIPT>
24
25</HEAD>
26
27<BODY BGCOLOR="white" onload="windowTitle();">
28<HR>
29
30
31<!-- ========= START OF TOP NAVBAR ======= -->
32<A NAME="navbar_top"><!-- --></A>
33<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
34<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
35<TR>
36<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
37<A NAME="navbar_top_firstrow"><!-- --></A>
38<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
39  <TR ALIGN="center" VALIGN="top">
40  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
41  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
42  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
43  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
44  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
45  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
46  </TR>
47</TABLE>
48</TD>
49<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
50</EM>
51</TD>
52</TR>
53
54<TR>
55<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
56&nbsp;PREV CLASS&nbsp;
57&nbsp;NEXT CLASS</FONT></TD>
58<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
59  <A HREF="index.html?ImportKey.html" target="_top"><B>FRAMES</B></A>  &nbsp;
60&nbsp;<A HREF="ImportKey.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
61&nbsp;<SCRIPT type="text/javascript">
62  <!--
63  if(window==top) {
64    document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
65  }
66  //-->
67</SCRIPT>
68<NOSCRIPT>
69  <A HREF="allclasses-noframe.html"><B>All Classes</B></A>
70</NOSCRIPT>
71
72
73</FONT></TD>
74</TR>
75<TR>
76<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
77  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
78<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
79DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
80</TR>
81</TABLE>
82<A NAME="skip-navbar_top"></A>
83<!-- ========= END OF TOP NAVBAR ========= -->
84
85<HR>
86<!-- ======== START OF CLASS DATA ======== -->
87<H2>
88Class ImportKey</H2>
89<PRE>
90java.lang.Object
91  <B>ImportKey</B>
92</PRE>
93<HR>
94<DL>
95<DT><PRE>public class <B>ImportKey</B><DT>extends java.lang.Object</DL>
96</PRE>
97
98<P>
99ImportKey.java
100
101 <p>This class imports a key and a certificate into a keystore
102 (<code>$home/keystore.ImportKey</code>). If the keystore is
103 already present, it is simply deleted. Both the key and the
104 certificate file must be in <code>DER</code>-format. The key must be
105 encoded with <code>PKCS#8</code>-format. The certificate must be
106 encoded in <code>X.509</code>-format.</p>
107
108 <p>Key format:</p>
109 <p><code>openssl pkcs8 -topk8 -nocrypt -in YOUR.KEY -out YOUR.KEY.der
110 -outform der</code></p>
111 <p>Format of the certificate:</p>
112 <p><code>openssl x509 -in YOUR.CERT -out YOUR.CERT.der -outform
113 der</code></p>
114 <p>Import key and certificate:</p>
115 <p><code>java comu.ImportKey YOUR.KEY.der YOUR.CERT.der</code></p><br />
116
117 <p><em>Caution:</em> the old <code>keystore.ImportKey</code>-file is
118 deleted and replaced with a keystore only containing <code>YOUR.KEY</code>
119 and <code>YOUR.CERT</code>. The keystore and the key has no password;
120 they can be set by the <code>keytool -keypasswd</code>-command for setting
121 the key password, and the <code>keytool -storepasswd</code>-command to set
122 the keystore password.
123 <p>The key and the certificate is stored under the alias
124 <code>importkey</code>; to change this, use <code>keytool -keyclone</code>.
125
126 Created: Fri Apr 13 18:15:07 2001
127 Updated: Fri Apr 19 11:03:00 2002
128<P>
129
130<P>
131<HR>
132
133<P>
134
135<!-- ======== CONSTRUCTOR SUMMARY ======== -->
136
137<A NAME="constructor_summary"><!-- --></A>
138<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
139<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
140<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
141<B>Constructor Summary</B></FONT></TH>
142</TR>
143<TR BGCOLOR="white" CLASS="TableRowColor">
144<TD><CODE><B><A HREF="ImportKey.html#ImportKey()">ImportKey</A></B>()</CODE>
145
146<BR>
147&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
148</TR>
149</TABLE>
150&nbsp;
151<!-- ========== METHOD SUMMARY =========== -->
152
153<A NAME="method_summary"><!-- --></A>
154<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
155<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
156<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
157<B>Method Summary</B></FONT></TH>
158</TR>
159<TR BGCOLOR="white" CLASS="TableRowColor">
160<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
161<CODE>static&nbsp;void</CODE></FONT></TD>
162<TD><CODE><B><A HREF="ImportKey.html#main(java.lang.String[])">main</A></B>(java.lang.String[]&nbsp;args)</CODE>
163
164<BR>
165&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Takes two file names for a key and the certificate for the key,
166 and imports those into a keystore.</TD>
167</TR>
168</TABLE>
169&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
170<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
171<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
172<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
173</TR>
174<TR BGCOLOR="white" CLASS="TableRowColor">
175<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
176</TR>
177</TABLE>
178&nbsp;
179<P>
180
181<!-- ========= CONSTRUCTOR DETAIL ======== -->
182
183<A NAME="constructor_detail"><!-- --></A>
184<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
185<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
186<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
187<B>Constructor Detail</B></FONT></TH>
188</TR>
189</TABLE>
190
191<A NAME="ImportKey()"><!-- --></A><H3>
192ImportKey</H3>
193<PRE>
194public <B>ImportKey</B>()</PRE>
195<DL>
196</DL>
197
198<!-- ============ METHOD DETAIL ========== -->
199
200<A NAME="method_detail"><!-- --></A>
201<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
202<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
203<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
204<B>Method Detail</B></FONT></TH>
205</TR>
206</TABLE>
207
208<A NAME="main(java.lang.String[])"><!-- --></A><H3>
209main</H3>
210<PRE>
211public static void <B>main</B>(java.lang.String[]&nbsp;args)</PRE>
212<DL>
213<DD><p>Takes two file names for a key and the certificate for the key,
214 and imports those into a keystore. Optionally it takes an alias
215 for the key.
216 <p>The first argument is the filename for the key. The key should be
217 in PKCS8-format.
218 <p>The second argument is the filename for the certificate for the key.
219 <p>If a third argument is given it is used as the alias. If missing,
220 the key is imported with the alias importkey
221 <p>The name of the keystore file can be controlled by setting
222 the keystore property (java -Dkeystore=mykeystore). If no name
223 is given, the file is named <code>keystore.ImportKey</code>
224 and placed in your home directory.
225<P>
226<DD><DL>
227<DT><B>Parameters:</B><DD><CODE>args</CODE> - [0] Name of the key file, [1] Name of the certificate file
228 [2] Alias for the key.</DL>
229</DD>
230</DL>
231<!-- ========= END OF CLASS DATA ========= -->
232<HR>
233
234
235<!-- ======= START OF BOTTOM NAVBAR ====== -->
236<A NAME="navbar_bottom"><!-- --></A>
237<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
238<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
239<TR>
240<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
241<A NAME="navbar_bottom_firstrow"><!-- --></A>
242<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
243  <TR ALIGN="center" VALIGN="top">
244  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
245  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
246  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
247  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
248  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
249  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
250  </TR>
251</TABLE>
252</TD>
253<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
254</EM>
255</TD>
256</TR>
257
258<TR>
259<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
260&nbsp;PREV CLASS&nbsp;
261&nbsp;NEXT CLASS</FONT></TD>
262<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
263  <A HREF="index.html?ImportKey.html" target="_top"><B>FRAMES</B></A>  &nbsp;
264&nbsp;<A HREF="ImportKey.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
265&nbsp;<SCRIPT type="text/javascript">
266  <!--
267  if(window==top) {
268    document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
269  }
270  //-->
271</SCRIPT>
272<NOSCRIPT>
273  <A HREF="allclasses-noframe.html"><B>All Classes</B></A>
274</NOSCRIPT>
275
276
277</FONT></TD>
278</TR>
279<TR>
280<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
281  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
282<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
283DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
284</TR>
285</TABLE>
286<A NAME="skip-navbar_bottom"></A>
287<!-- ======== END OF BOTTOM NAVBAR ======= -->
288
289<HR>
290
291</BODY>
292</HTML>