Avatar
Please consider registering
guest
sp_LogInOut Log Insp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSSsp_TopicIcon
Server - SecureIdentityException
May 5, 2026
18:38, EEST
Avatar
riverplate
Member
Members
Forum Posts: 6
Member Since:
August 5, 2025
sp_UserOfflineSmall Offline

Hi, I am creating an instance of a `UaServer` this way:

var newServer = new UaServer();
ApplicationDescription appDescription = new ApplicationDescription();
appDescription.setApplicationName(new LocalizedText(“SimpleServer”, Locale.ENGLISH));
appDescription.setApplicationUri(“urn:localhost:UA:SimpleServer”);
appDescription.setProductUri(“urn:prosysopc.com:UA:SimpleServer”);
appDescription.setApplicationType(ApplicationType.Server);
ApplicationIdentity identity = ApplicationIdentity.loadOrCreateCertificate(
appDescription,
“MyCompany”, // Organization
null, // Common Name for certificate
null, // Hostname override
true // Create if missing
);
newServer.setApplicationIdentity(identity);
newServer.addUserTokenPolicy(UserTokenPolicies.ANONYMOUS);
newServer.init();

Everything seemed to work fine, until I noticed that on a few PCs I get the error:

com.prosysopc.ua.SecurityIndetityException: Private key cannot be loaded from file SimpleServer_2048.pem
at com.prosysopc.ua.ApplicationIdentity.loadOrCreateKeyPair(SourceFile:930)
Caused by: java.io.IOException: Short read of DER length
at java.base/sun.security.util.DerInputStream.getLength(DerInputStream.java:588)
at java.base/sun.security.util.DerValue.init(DerValue.java:390)
at java.base/sun.security.util.DerValue.(DerValue.java:331)
at java.base/sun.security.util.DerValue.(DerValue.java:344)
at java.base/sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1993)
at java.base/java.security.KeyStore.load(KeyStore.java:1479)
at com.prosysopc.ua.stack.utils.CertificateUtils.loadFromKeyStore(SourceFile:660)
at com.prosysopc.ua.stack.transport.security.PrivKey.loadFromKeyStore(SourceFile:200)
at com.prosysopc.ua.stack.transport.security.PrivKey.loadFromKeyStore(SourceFile:183)
at com.prosysopc.ua.ApplicationIdentity.loadOrCreateKeyPair(SourceFile:925)

any idea on where the issue might be? The certificates are created by the SDK and never touched by any other process.

Thanks!

May 6, 2026
13:49, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1105
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

What SDK version you are using?

Any option you could send one of the .pem to jsdk-support@prosysopc.com?

Alternatively, you could try loading them manually using (exactly these methods) com.prosysopc.ua.stack.utils.FileUtil.readFile(File) and then PrivKey.load(byte[], null) on the returned byte[]. This should throw an Exception that might help to explain what happened. In the loadOrCreate there is a fallback to try in another format (loadFromKeyStore), and the posted error is from that, but it failed before that (that would output a DEBUG level log only) because SDK writes them in format the load(..) should be able to load.

So my guess would be that somehow the writing of the .pem didn’t work or it got corrupted somehow (or the filesystem did it afterwards somehow). SDK doesn’t load them back on the method call that created them, it would only fail on the next call.

Also as a sidenote, unless I missed something, you are calling https://documentation.prosysopc.com/JSDK/javadoc/com/prosysopc/ua/ApplicationIdentity.html#loadOrCreateCertificate-com.prosysopc.ua.stack.core.ApplicationDescription-java.lang.String-java.lang.String-java.io.File-boolean-java.lang.String…-
whose signature is
loadOrCreateCertificate(ApplicationDescription applicationDescription, String organisation, String privateKeyPassword, File path, boolean enableRenew, String… hostNames) so your comments on the parameters are wrong. You give a null File as the folder where the keys would be stored so they become relative Files instead so it is possibly dependent on how your application is executed could the previously created be found. The boolean enableRenew means SDK will attemt to re-create the certificate if it expires. By default the certificates SDK creates are valid for 10 years. Thus, I think that has not happened yet.

Forum Timezone: Europe/Helsinki
Most Users Ever Online: 1919
Currently Online:
Guest(s) 45
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 146
rocket science: 114
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 904
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1587
Posts: 6693
Newest Members:
Taylorlly, heathdallachy85, dewittfrantz2, devonkeenan47, Michaelkam, chnmrc, ahmad.qureshi3@se.abb.com, connieorchard88, carlotae86, otiliabanks
Moderators: Jouni Aro: 1058, Pyry: 1, Petri: 1, Bjarne Boström: 1081, Jimmy Ni: 26, Matti Siponen: 370, Lusetti: 1
Administrators: admin: 1