-
Your custom script needs to be use OneDev SSL factory to work with self-signed certificate. Something like this:
def connection = url.openConnection() if (connection instanceof javax.net.ssl.HttpsURLConnection) { def sslFactory = io.onedev.server.OneDev.getInstance( nl.altindag.ssl.SSLFactory.class ) connection.sslSocketFactory = sslFactory.sslSocketFactory connection.hostnameVerifier = sslFactory.hostnameVerifier } -
Name Previous Value Current Value Type
Bug
Question
-
Thanks Robin, that is good to know.
-
Previous Value Current Value Open
Closed
-
After adding your suggestions, I got the following error
Error: No such property: sslSocketFactory for class: sun.net.www.protocol.https.HttpsURLConnectionImpl Possible solutions: SSLSocketFactoryThis is what my script looks like - let me know if I missed anything:
def progetUrl = "https://proget.domain.com" def feedName = "my-powershell-modules" try { def url = new URL("${progetUrl}/api/packages/${feedName}/latest") def connection = url.openConnection() if (connection instanceof javax.net.ssl.HttpsURLConnection) { def sslFactory = io.onedev.server.OneDev.getInstance( nl.altindag.ssl.SSLFactory.class ) connection.sslSocketFactory = sslFactory.sslSocketFactory connection.hostnameVerifier = sslFactory.hostnameVerifier } def response = url.text def mapper = io.onedev.server.OneDev.getInstance(com.fasterxml.jackson.databind.ObjectMapper.class) def packages = mapper.readValue(response, List.class) def choices = [:] packages.findAll { it.name?.startsWith("MY") }.each { pkg -> def key = pkg.name + " (" + pkg.version + ")" choices.put(key, null) } return choices } catch (Exception e) { def errKey = "Error: " + e.message def choices = [:] choices.put(errKey, null) return choices } -
Previous Value Current Value Closed
Open
-
The Groovy property syntax does not handle the acronym-style JavaBean property correctly here. Please use the explicit setter methods:
connection.setSSLSocketFactory(sslFactory.getSslSocketFactory()) connection.setHostnameVerifier(sslFactory.getHostnameVerifier())Also replace:
def response = url.textwith:
def response = connection.inputStream.getText("UTF-8")url.textopens another connection, so it would not use the SSL configuration applied toconnection. -
Thank you Robin, that worked.
-
Previous Value Current Value Open
Closed
| Type |
Question
|
| Priority |
Normal
|
| Assignee | |
| Labels |
No labels
|
Issue Votes (0)
When using Groovy scripts in custom issue field definitions, any HTTPS request to a host signed by an internal CA fails with an SSL handshake error, even when the CA certificates have been correctly imported into OneDev's
conf\trust-certsdirectory.The error the Groovy script shows is
We have an internal repository where we host internally built modules. For enhanced issue tracking, I wanted to add an
Enumtype custom field where whoever opens an issue could choose which module and version this was in relation to. The modules get published to an internal NuGet feed, so the Groovy script basically parses the NuGet feed and returns a list of these modules. However, this is what the custom field shows.Example of the Groovy script below