Skip to content

Commit f06217f

Browse files
committed
[releng] OSGi: Ensure the BC security provider can be found
BouncyCastleSecurityProviderRegistrar references the BC security provider only reflectively. It lives in a package that is not referenced explicitly anywhere. To be able to find org.bouncycastle.jce.provider.BouncyCastleProvider, the package must be on the bundle classpath in OSGi. It wasn't, since there was no "normal" reference to it. Add an optional dependency explicitly in the generated MANIFEST.MF of sshd-osgi.
1 parent 5c80258 commit f06217f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

pom.xml

+2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
<sshd.tests.rerun.count>2</sshd.tests.rerun.count>
135135

136136
<dependency.download.silent>true</dependency.download.silent>
137+
<bnd.extraImports># A comment indicates 'none'</bnd.extraImports>
137138
</properties>
138139

139140
<profiles>
@@ -1476,6 +1477,7 @@
14761477
<Import-Package><![CDATA[
14771478
org.apache.sshd*;version="$<range;[===,=+);$<maven_version;${project.version}>>",
14781479
org.slf4j*;version="$<range;[==,${slf4j.upper.bound})>",
1480+
${bnd.extraImports}
14791481
*
14801482
]]></Import-Package>
14811483
<Export-Package>*;-noimport:=true</Export-Package>

sshd-osgi/pom.xml

+13
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@
3434

3535
<properties>
3636
<projectRoot>${project.basedir}/..</projectRoot>
37+
<!--
38+
The BC security provider class resides in a package that is referenced nowhere, except reflectively in the BouncyCastleSecurityRegistrar.
39+
The (optional) package import will thus be missing in the generated MANIFEST.MF. However, the BouncyCastleSecurityRegistrar expects to find
40+
class org.bouncycastle.jce.provider.BouncyCastleProvider on the classpath; otherwise its isSupported() returns false and Bouncycastle is
41+
considered not available.
42+
43+
However, in OSGi the package will not be on the bundle classpath if there is no Import-Package for it. (And using a Require-Bundle would restrict
44+
bundle wiring too much.)
45+
46+
Arguably this is a shortcoming of the BouncyCastleSecurityRegistrar. For the EdDSASecurityProviderRegistrar, this problem does not exist
47+
since the security provider is in a package that is also referenced elsewhere.
48+
-->
49+
<bnd.extraImports>org.bouncycastle.jce.provider;version="$$&lt;range;[==,+);${bouncycastle.version}>";resolution:=optional,</bnd.extraImports>
3750
</properties>
3851

3952
<dependencies>

0 commit comments

Comments
 (0)