equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2003,2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
63 * ReadP12_OpenSSL: Read p12 key store from OpenSSL. |
63 * ReadP12_OpenSSL: Read p12 key store from OpenSSL. |
64 */ |
64 */ |
65 |
65 |
66 public class ReadP12Test { |
66 public class ReadP12Test { |
67 |
67 |
68 private final static String IN_KETYSTORE_TYPE = "pkcs12"; |
68 private final static String IN_KEYSTORE_TYPE = "pkcs12"; |
69 private final static String IN_KEYSTORE_PRV = "SunJSSE"; |
|
70 private final static String IN_STORE_PASS = "pass"; |
69 private final static String IN_STORE_PASS = "pass"; |
71 |
70 |
72 public static void main(String args[]) throws Exception { |
71 public static void main(String args[]) throws Exception { |
73 |
72 |
74 ReadP12Test jstest = new ReadP12Test(); |
73 ReadP12Test jstest = new ReadP12Test(); |
122 |
121 |
123 // Initialize KeyStore |
122 // Initialize KeyStore |
124 String dir = System.getProperty("test.src", "."); |
123 String dir = System.getProperty("test.src", "."); |
125 String keystorePath = dir + File.separator + "certs" + File.separator |
124 String keystorePath = dir + File.separator + "certs" + File.separator |
126 + "readP12"; |
125 + "readP12"; |
127 inputKeyStore = KeyStore |
126 inputKeyStore = KeyStore.getInstance(IN_KEYSTORE_TYPE); |
128 .getInstance(IN_KETYSTORE_TYPE, IN_KEYSTORE_PRV); |
|
129 // KeyStore have encoded by Base64.getMimeEncoder().encode(),need decode |
127 // KeyStore have encoded by Base64.getMimeEncoder().encode(),need decode |
130 // first. |
128 // first. |
131 byte[] input = Files.readAllBytes(Paths.get(keystorePath, inKeyStore)); |
129 byte[] input = Files.readAllBytes(Paths.get(keystorePath, inKeyStore)); |
132 ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64 |
130 ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64 |
133 .getMimeDecoder().decode(input)); |
131 .getMimeDecoder().decode(input)); |