Skip to content

Commit 8c4a299

Browse files
committed
NetBeans 11.3 regression fixed - allow to install nbms signed by a valid certificate
1 parent 3d580b2 commit 8c4a299

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
org.graalvm.visualvm.modules.appui.keystore.VisualVMKeyStoreProvider
2+
org.graalvm.visualvm.modules.appui.keystore.CacertsKeyStoreProvider
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
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
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package org.graalvm.visualvm.modules.appui.keystore;
27+
28+
import java.io.File;
29+
import java.io.FileInputStream;
30+
import java.io.IOException;
31+
import java.security.KeyStore;
32+
import java.util.logging.Level;
33+
import java.util.logging.Logger;
34+
import org.netbeans.spi.autoupdate.KeyStoreProvider;
35+
36+
/**
37+
* The cacerts keystore with the configured CA certificates.
38+
*
39+
* @author Tomas Hurka
40+
*/
41+
public class CacertsKeyStoreProvider implements KeyStoreProvider {
42+
43+
private static String getCacerts() {
44+
String fs = File.separator;
45+
// ${java_home}/lib/security/cacerts
46+
return System.getProperty("java.home") + fs
47+
+ "lib" + fs + "security" + fs + "cacerts";
48+
}
49+
50+
/**
51+
* Returns the cacerts keystore with the configured CA certificates.
52+
*/
53+
@Override
54+
public KeyStore getKeyStore() {
55+
KeyStore keyStore = null;
56+
FileInputStream is = null;
57+
58+
try {
59+
File file = new File(getCacerts());
60+
if (!file.exists()) {
61+
return null;
62+
}
63+
64+
keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
65+
is = new FileInputStream(file);
66+
keyStore.load(is, null);
67+
} catch (Exception ex) {
68+
Logger.getLogger("global").log(Level.INFO, ex.getMessage(), ex);
69+
} finally {
70+
try {
71+
if (is != null) is.close();
72+
} catch (IOException ex) {
73+
assert false : ex;
74+
}
75+
}
76+
return keyStore;
77+
}
78+
79+
@Override
80+
public TrustLevel getTrustLevel() {
81+
return TrustLevel.VALIDATE_CA;
82+
}
83+
}

0 commit comments

Comments
 (0)