Skip to content

Commit 04d98f9

Browse files
authored
Merge pull request #196 from SimoneTinella/fix_issue_194
Fixed issue #194 (RuntimeException caused by BC provider on Android)
2 parents eb5bf1e + 8d6a463 commit 04d98f9

File tree

8 files changed

+49
-42
lines changed

8 files changed

+49
-42
lines changed

.gitignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ tmp/
33
javadoc/
44
bin/
55
/test-output
6-
target
6+
target
7+
/.idea
78

8-
*.der
9-
*.pem
9+
*.der
10+
*.pem
1011
.settings
1112
.classpath
1213
.project

Changelog.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
1.4.1.1
2+
Fixed (#194): SpongyCastle provider is now automatically picked in BouncyCastleUtils class
3+
14
1.4.1
25
New (#185): Support for ReverseHello (see the ReverseHelloClientServerExample)
36
New: Better configuration of initial timeouts in opc.tcp connections (see OpcTcpSettings)

codegen/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22
<modelVersion>4.0.0</modelVersion>
33
<artifactId>opc-ua-stack-codegen</artifactId>
4-
<version>1.4.1-SNAPSHOT</version>
4+
<version>1.4.1.1-SNAPSHOT</version>
55
<groupId>org.opcfoundation.ua</groupId>
66
<build>
77
<plugins>

examples/basic/pom.xml

+13-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.opcfoundation.ua</groupId>
44
<artifactId>opc-ua-stack-examples</artifactId>
5-
<version>1.4.1-SNAPSHOT</version>
5+
<version>1.4.1.1-SNAPSHOT</version>
66
<name>examples</name>
77
<properties>
88
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -64,12 +64,12 @@
6464
</descriptors>
6565
</configuration>
6666
<executions>
67-
<execution>
68-
<id>make-assembly</id>
69-
<phase>package</phase>
70-
<goals>
71-
<goal>single</goal>
72-
</goals>
67+
<execution>
68+
<id>make-assembly</id>
69+
<phase>package</phase>
70+
<goals>
71+
<goal>single</goal>
72+
</goals>
7373
</execution>
7474
</executions>
7575
</plugin>
@@ -120,12 +120,12 @@
120120
</programs>
121121
</configuration>
122122
<executions>
123-
<execution>
124-
<id>app-assembly</id>
125-
<phase>package</phase>
126-
<goals>
127-
<goal>assemble</goal>
128-
</goals>
123+
<execution>
124+
<id>app-assembly</id>
125+
<phase>package</phase>
126+
<goals>
127+
<goal>assemble</goal>
128+
</goals>
129129
</execution>
130130
</executions>
131131
</plugin>

examples/publisher/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.opcfoundation.ua</groupId>
44
<artifactId>azure-client-publisher-sample</artifactId>
5-
<version>1.4.1-SNAPSHOT</version>
5+
<version>1.4.1.1-SNAPSHOT</version>
66
<name>Azure IotHub Client Publisher Sample</name>
77
<properties>
88
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

graveyard/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>org.opcfoundation.ua</groupId>
66
<artifactId>opc-ua-stack-extras</artifactId>
7-
<version>1.4.1-SNAPSHOT</version>
7+
<version>1.4.1.1-SNAPSHOT</version>
88
<name>extras</name>
99
<properties>
1010
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

pom.xml

+19-16
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.opcfoundation.ua</groupId>
44
<artifactId>opc-ua-stack</artifactId>
5-
<version>1.4.1-SNAPSHOT</version>
5+
<version>1.4.1.1-SNAPSHOT</version>
66
<name>OPC Foundation Unified Architecture Java Stack</name>
77
<properties>
88
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -91,8 +91,11 @@
9191
</additionalJOptions>
9292
-->
9393
<!-- these are for javadoc:fix goal -->
94-
<fixTags>param,return,throws</fixTags>
95-
<additionalparam>${javadoc.arg}</additionalparam>
94+
<fixTags>param,return,throws</fixTags>
95+
96+
<additionalJOption>${javadoc.arg}</additionalJOption>
97+
98+
<!-- <additionalparam>${javadoc.arg}</additionalparam>-->
9699
<archive>
97100
<addMavenDescriptor>false</addMavenDescriptor>
98101
</archive>
@@ -111,27 +114,27 @@
111114
<artifactId>jacoco-maven-plugin</artifactId>
112115
<version>0.7.6.201602180812</version>
113116
<executions>
114-
<execution>
115-
<id>prepare-unit-tests</id>
116-
<goals>
117-
<goal>prepare-agent</goal>
117+
<execution>
118+
<id>prepare-unit-tests</id>
119+
<goals>
120+
<goal>prepare-agent</goal>
118121
</goals>
119122
<configuration>
120123
<excludes>
121124
<exclude>org.opcfoundation.ua.core.Identifiers</exclude>
122125
</excludes>
123-
</configuration>
126+
</configuration>
124127
</execution>
125-
<execution>
126-
<id>prepare-integration-tests</id>
127-
<goals>
128-
<goal>prepare-agent-integration</goal>
128+
<execution>
129+
<id>prepare-integration-tests</id>
130+
<goals>
131+
<goal>prepare-agent-integration</goal>
129132
</goals>
130133
<configuration>
131134
<excludes>
132135
<exclude>org.opcfoundation.ua.core.Identifiers</exclude>
133136
</excludes>
134-
</configuration>
137+
</configuration>
135138
</execution>
136139
</executions>
137140
</plugin>
@@ -270,11 +273,11 @@
270273
</dependency>
271274
</dependencies>
272275
<profiles>
273-
<profile>
276+
<profile>
274277
<id>jdk6</id>
275278
<properties>
276279
<javadoc.arg></javadoc.arg>
277-
</properties>
280+
</properties>
278281
<build>
279282
<plugins>
280283
<plugin>
@@ -311,7 +314,7 @@
311314
</configuration>
312315
</plugin>
313316
</plugins>
314-
</build>
317+
</build>
315318
</profile>
316319
</profiles>
317320
</project>

src/main/java/org/opcfoundation/ua/utils/BouncyCastleUtils.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public class BouncyCastleUtils {
8484
// startDate, expiryDate, dn,
8585
// keyPair.getPublic());
8686
// ContentSigner signer = new JcaContentSignerBuilder("SHA1withRSA")
87-
// .setProvider("BC").build(keyPair.getPrivate());
88-
// return new JcaX509CertificateConverter().setProvider("BC")
87+
// .setProvider(CryptoUtil.getSecurityProviderName()).build(keyPair.getPrivate());
88+
// return new JcaX509CertificateConverter().setProvider(CryptoUtil.getSecurityProviderName())
8989
// .getCertificate(certBldr.build(signer));
9090
// }
9191

@@ -149,11 +149,11 @@ expiryDate, new X500Principal(commonName),
149149
ContentSigner signer;
150150
try {
151151
signer = new JcaContentSignerBuilder(CertificateUtils.getCertificateSignatureAlgorithm())
152-
.setProvider("BC").build(privateKey);
152+
.setProvider(CryptoUtil.getSecurityProviderName()).build(privateKey);
153153
} catch (OperatorCreationException e) {
154154
throw new GeneralSecurityException("Failed to sign the certificate", e);
155155
}
156-
return new JcaX509CertificateConverter().setProvider("BC")
156+
return new JcaX509CertificateConverter().setProvider(CryptoUtil.getSecurityProviderName())
157157
.getCertificate(certBldr.build(signer));
158158
}
159159

@@ -299,9 +299,9 @@ public static X509Certificate generateCertificate(String domainName, PublicKey p
299299
//***** generate certificate ***********/
300300
try {
301301
ContentSigner signer = new JcaContentSignerBuilder(
302-
CertificateUtils.getCertificateSignatureAlgorithm()).setProvider("BC")
302+
CertificateUtils.getCertificateSignatureAlgorithm()).setProvider(CryptoUtil.getSecurityProviderName())
303303
.build(signerKey);
304-
return new JcaX509CertificateConverter().setProvider("BC")
304+
return new JcaX509CertificateConverter().setProvider(CryptoUtil.getSecurityProviderName())
305305
.getCertificate(certBldr.build(signer));
306306
} catch (OperatorCreationException e) {
307307
throw new GeneralSecurityException(e);
@@ -326,7 +326,7 @@ public static void writeToPem(Object key, File savePath, String password, String
326326
pemWrt.writeObject(key);
327327
else {
328328
char[] pw = password.toCharArray();
329-
PEMEncryptor encryptor = new JcePEMEncryptorBuilder(algorithm).setProvider("BC").setSecureRandom(CryptoUtil.getRandom()).build(pw);
329+
PEMEncryptor encryptor = new JcePEMEncryptorBuilder(algorithm).setProvider(CryptoUtil.getSecurityProviderName()).setSecureRandom(CryptoUtil.getRandom()).build(pw);
330330

331331
pemWrt.writeObject(key, encryptor);
332332
}

0 commit comments

Comments
 (0)