9:35, EEST
December 12, 2018
I am trying to create a Application Identity to connect to a OPC server using Basis254SignandEncrypt with a username and password Authentication. I get this IO Exception
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(Unknown Source)
at com.prosysopc.ua.stack.utils.FileUtil.writeFile(SourceFile:116)
at com.prosysopc.ua.stack.transport.security.Cert.save(SourceFile:194)
at com.prosysopc.ua.ApplicationIdentity.loadOrCreateKeyPair(SourceFile:632)
at com.prosysopc.ua.ApplicationIdentity.loadOrCreateCertificate(SourceFile:466)
at com.prosysopc.ua.ApplicationIdentity.loadOrCreateCertificate(SourceFile:358)
My code looks like this
certStore = new PkiDirectoryCertificateStore();
validator = new DefaultCertificateValidator(certStore);
client.setCertificateValidator(validator);
validator.setValidationListener(validationListener);
// *** Certificates
privatePath = new File(certStore.getBaseDir(),”privatefile”);
privatePath.canWrite(); // return a true to show that the directory is writable
privatePath.getAbsolutePath();// returns the correct path to the file
int[] keySizes = new int[] {0,4096};
Set supportedHttpsModes = new HashSet();
supportedHttpsModes.addAll(HttpsSecurityPolicy.ALL_102);
supportedHttpsModes.addAll(HttpsSecurityPolicy.ALL_103);
supportedHttpsModes.addAll(HttpsSecurityPolicy.ALL_104);
client.getHttpsSettings().setHttpsSecurityPolicies(supportedHttpsModes);
client.getHttpsSettings().setCertificateValidator(validator);
// Define a custom certificate validator for the HTTPS certificates
applicationDescription = new ApplicationDescription();
applicationDescription.setApplicationName(new LocalizedText(Applicationidentity + “GKNAerospace”));
applicationDescription.setApplicationUri(“urn:” + APPLICATIONURI + Applicationidentity);
applicationDescription.setProductUri(“urn:” + PRODUCTURI);
applicationDescription.setApplicationType(ApplicationType.Client);
try {
ApplicationIdentity.loadOrCreateCertificate(applicationDescription, “opcclient”, “opcclient”, privatePath, null, keySizes,true);
} catch (SecureIdentityException | IOException e) {
e.printStackTrace(); // I get error at this point
}
What is the problem ?
14:37, EEST
Moderators
February 11, 2020
Hello swaj!
The certificates are stored to PKI\CA folder of your working directory by default. Could you verify that your working directory allows you to write files into it? Alternatively, you can try to initialize PkiDirectoryCertificateStore with an absolute path, e.g. “C:\\Folder1\\Folder2\\PKI”, of a folder that allows writing files into it.
BR,
Matti
18:07, EEST
December 12, 2018
Matti Siponen said
Hello swaj!The certificates are stored to PKI\CA folder of your working directory by default. Could you verify that your working directory allows you to write files into it? Alternatively, you can try to initialize PkiDirectoryCertificateStore with an absolute path, e.g. “C:\\Folder1\\Folder2\\PKI”, of a folder that allows writing files into it.
BR,
Matti
Hello Matti Siponen
I tried to verify that I have user rights by actually writing a file using a another Java program into the same folder. The error I get still exists.
9:18, EEST
Moderators
February 11, 2020
Hello swaj!
This exception could also be caused by attempting to write a file with filename containing invalid characters. In Windows based systems these invalid characters are , :, “, /, \, |, ? and *. Please verify that your Applicationidentity used to set application name doesn’t contain any of these characters.
BR,
Matti
11:07, EEST
December 12, 2018
Matti Siponen said
Hello swaj!This exception could also be caused by attempting to write a file with filename containing invalid characters. In Windows based systems these invalid characters are , :, “, /, \, |, ? and *. Please verify that your Applicationidentity used to set application name doesn’t contain any of these characters.
BR,
Matti
This is the path I use
File privatePath = new File(“C:\\Users\\Admin\\Desktop\\certs\\privatefile”);
I can write to a file using the same path by using the java.io.fileWritter. Problem still exists !!!!!
Thank you
12:11, EEST
Moderators
February 11, 2020
There should be no problem with your path. However, if your Applicationidentity contains invalid characters, it will cause this exception. Please specify the value of Applicationidentity used in the following line of the code:
applicationDescription.setApplicationName(new LocalizedText(Applicationidentity + “GKNAerospace”));
Most Users Ever Online: 1919
Currently Online: mithun
31 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 735
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1523
Posts: 6449
Newest Members:
rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, Thomassnism, biancacraft16Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1