Skip to content

Commit 552a9e9

Browse files
committed
fix(weaver): resource incorrect permission assignment
Primary change: Grant full permissions to owner only Fixes #2769 Signed-off-by: musicboy0322 <[email protected]>
1 parent 8924727 commit 552a9e9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

weaver/sdks/corda/src/main/kotlin/org/hyperledger/cacti/weaver/sdk/corda/CredentialsExtractor.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ private static String getRootCertPEM(KeyStore ks, String trustStore, String temp
151151
File outputDir = new File(tempStore + "root/");
152152
if (!outputDir.exists()) {
153153
outputDir.mkdirs();
154+
// remove all privilege from all previous users
155+
outputDir.setReadable(false, false);
156+
outputDir.setWritable(false, false);
157+
outputDir.setExecutable(false, false);
158+
// add all privilege to owner
159+
outputDir.setReadable(true, true);
160+
outputDir.setWritable(true, true);
161+
outputDir.setExecutable(true, true);
154162
}
155163
JcaPEMWriter xwriter = new JcaPEMWriter(new FileWriter(tempStore + "root/rootcert.pem"));
156164
xwriter.writeObject(xcert);
@@ -201,6 +209,14 @@ private static Vector<String> getCertChain(KeyStore ks, String nodeKeyStorePath,
201209
File outputDir = new File(tmpStore);
202210
if (!outputDir.exists()) {
203211
outputDir.mkdirs();
212+
// remove all permissions from all users (including owner)
213+
outputDir.setReadable(false, false);
214+
outputDir.setWritable(false, false);
215+
outputDir.setExecutable(false, false);
216+
// grant full permissions to owner only
217+
outputDir.setReadable(true, true);
218+
outputDir.setWritable(true, true);
219+
outputDir.setExecutable(true, true);
204220
}
205221
String filePath = tmpStore + tmpCertfiles[i] + ".pem";
206222
JcaPEMWriter xwriter = new JcaPEMWriter(new FileWriter(filePath));

0 commit comments

Comments
 (0)