14:33, EET
November 15, 2017
Hi all,
i am using the Java Client SDK in an android app. its a simple browser which also can subscribe to sensor values.
my problem is that as soon as i want to establish a connection using a security mode other then .NONE it throws a ClassCastExeption.
More specific:
java.lang.ClassCastException: com.android.org.conscrypt.OpenSSLRSAPrivateKey cannot be cast to java.security.interfaces.RSAPrivateCrtKey
What am i missing? Looking forward to hearing from you. Thanks
Responsibe Code:
ApplicationDescription appDescription = new ApplicationDescription();
appDescription.setApplicationName(new LocalizedText(“AndroidOpcuaBrowser”,
Locale.ENGLISH));
String android_id = Settings.Secure.getString(
mContext.getContentResolver(),
Settings.Secure.ANDROID_ID);
appDescription.setApplicationUri(“urn:” + android_id + “:UA:AndroidOpcuaBrowser”);
appDescription.setProductUri(“urn:hahnschickard.de:UA:AndroidOpcuaBrowser”);
appDescription.setApplicationType(ApplicationType.Client);
PkiFileBasedCertificateValidator validator = new PkiFileBasedCertificateValidator(
mContext.getFilesDir().getPath() + “/PKI/CA”);
Log.d(“PkiPath”, mContext.getFilesDir().getPath() + “/PKI/CA”);
validator.setValidationListener(new CertificateValidationListener() {
@Override
public PkiFileBasedCertificateValidator.ValidationResult onValidate(
Cert cert, ApplicationDescription applicationDescription,
EnumSet enumSet) {
return PkiFileBasedCertificateValidator.ValidationResult.AcceptPermanently;
}
});
mClient.setCertificateValidator(validator);
ApplicationIdentity identity = ApplicationIdentity
.loadOrCreateCertificate(appDescription, “Sample Organisation”,
/* Private Key Password */”opcua”,
/* Key File Path */new File(validator.getBaseDir(), “private”),
/* Enable renewing the certificate */ true);
identity.setApplicationDescription(appDescription);
mClient.setApplicationIdentity(identity);
mClient.setTimeout(60000);
mClient.setSecurityMode(SecurityMode.BASIC128RSA15_SIGN);
mClient.setUserIdentity(new UserIdentity());
mClient.connect();
Log:
E/AndroidRuntime: FATAL EXCEPTION: Thread-5
Process: de.hahn_schickard.opcuaexplorer, PID: 1640
java.lang.ClassCastException: com.android.org.conscrypt.OpenSSLRSAPrivateKey cannot be cast to java.security.interfaces.RSAPrivateCrtKey
at org.opcfoundation.ua.transport.security.ScCryptoProvider.signAsymm(Unknown Source)
at org.opcfoundation.ua.transport.tcp.impl.ChunkAsymmEncryptSigner.sign(Unknown Source)
at org.opcfoundation.ua.transport.tcp.impl.ChunkAsymmEncryptSigner.run(Unknown Source)
at org.opcfoundation.ua.transport.tcp.io.TcpConnection.sendAsymmChunk(Unknown Source)
at org.opcfoundation.ua.transport.tcp.io.TcpConnection.sendRequest(Unknown Source)
at org.opcfoundation.ua.transport.tcp.io.SecureChannelTcp.createSecureChannel(Unknown Source)
at org.opcfoundation.ua.transport.tcp.io.SecureChannelTcp.open(Unknown Source)
at org.opcfoundation.ua.application.Client.createSecureChannel(Unknown Source)
at com.prosysopc.ua.client.UaClient.m(Unknown Source)
at com.prosysopc.ua.client.UaClient.connect(Unknown Source)
at de.hahn_schickard.opcuaexplorer.OPCUAService$ConnectThread.run(OPCUAService.java:421)
17:42, EET
February 18, 2015
Hi David,
Your problem is most likely caused by a wrong crypto provider. When developing for Android, you need to use SpongyCastle instead of the default BouncyCastle. Typically the SDK takes care of this, but the current version has a known issue where the selection isn’t made and will be fixed in a future release. Please add the following line before making any OPC UA connections:
CryptoUtil.setCryptoProvider(new ScJceCryptoProvider());
Please note that you have to include the SpongyCastle libraries delivered with the SDK in your project.
Let us know if you have any further issues!
10:32, EET
November 15, 2017
11:22, EEST
June 2, 2019
hey! just a small query.
I am using the Prosys SDK for Java. And i am kinda stuck at figuring out the following issue.
CODE:
PkiFileBasedCertificateValidator validator = new PkiFileBasedCertificateValidator(
getFilesDir().getPath() + “/PKI/CA”);
validator.setValidationListener(new CertificateValidationListener() {
@Override
public PkiFileBasedCertificateValidator.ValidationResult onValidate(
Cert cert, ApplicationDescription applicationDescription,
EnumSet enumSet) {
return PkiFileBasedCertificateValidator.ValidationResult.AcceptPermanently;
}
});
client.setCertificateValidator(validator);
The “PkiFileBasedCertificateValidator” and “CertificateValidationListener” are not recognised in Android Studio.
Any library file i am missing on?
11:23, EEST
June 2, 2019
hey! just a small query.
I am using the Prosys SDK for Java. And i am kinda stuck at figuring out the following issue.
CODE:
PkiFileBasedCertificateValidator validator = new PkiFileBasedCertificateValidator(
getFilesDir().getPath() + “/PKI/CA”);
validator.setValidationListener(new CertificateValidationListener() {
@Override
public PkiFileBasedCertificateValidator.ValidationResult onValidate(
Cert cert, ApplicationDescription applicationDescription,
EnumSet enumSet) {
return PkiFileBasedCertificateValidator.ValidationResult.AcceptPermanently;
}
});
client.setCertificateValidator(validator);
The “PkiFileBasedCertificateValidator” and “CertificateValidationListener” are not recognised in Android Studio.
Any library file i am missing on?
12:26, EEST
April 3, 2012
When you make a post please do not post it to multiple forums. Additionally unless you had the same exact problem, do not post on old threads. If you have a new problem, start a new thread. I now answered this in https://forum.prosysopc.com/forum/prosys-opc-ua-client-for-android/how-to-get-the-nodeids-of-a-server-coded-in-c-on-the-android-ui/.
Most Users Ever Online: 1919
Currently Online:
10 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: 736
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, ThomassnismModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1