SSL error JRJC

Is there a way to attach a file to Jira issue using JRJC 2.0 ? If yes, can you give me some examples of it? Also, is there a way to ignore ssl errors in JRJC? The following code (using earlier version of JRJC) gives SSL certificate validation error. If there is no way to ignore, from where can I get the certificate to add to my java keystore?


final jiraServerUri = new<jira company url>);

FileInputStream fileStreamPath = new FileInputStream(filepath);

JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();

// final JiraRestClientFactory factory = new JiraRestClientFactory();

NullProgressMonitor pm = new NullProgressMonitor();

System.out.println("Server Url :"+jiraServerUri);

// JiraRestClient restClient = new JiraRestClient();

String newKey = <issue-key>;

final AttachmentUri = new"/rest/api/2/issue/"+newKey+"/attachments");

JiraRestClient restClient = factory.createWithBasicHttpAuthentication(AttachmentUri,<username>,<password>);

Issue issue1 = restClient.getIssueClient().getIssue(newKey,pm);

System.out.println("URI :"+issue1.getAttachmentsUri());

//restClient.getIssueClient().addAttachment(pm,issue1.getAttachmentsUri(), fileStreamPath , imageName);

restClient.getIssueClient().addAttachment(pm,AttachmentUri, fileStreamPath, "Test Image");

// return attachmentfilepath;

3 answers

1 accepted

You can find example code for adding atachments in testAddAttachment:
For SSL problem you can just add certificate to keystore and use that keystore.
To get certificate you can use openssl command line tool:
openssl s_client -connect ${your-jira-url}:${ssl-port} -showcerts

How to add key to keystore:
How to tell java to use your keystore:
Puting this together:
# Get cert (you need copy the cert and save to file my.jks)
openssl s_client -connect localhost:8090 -showcerts 

# Add cert to keystore
keytool -import -v -trustcacerts -alias localhost-8090 -file some.cert -keystore my.jks -keypass changeit -storepass changeit

# Run app
java ...


Thank you for the response. I've added the certificate to my keystore and that error seems to have gone away. However, I'm getting the following error on getIssue:

"The method getIssue from type IssueRestClient refers to missing type Promise".

From where can I import com.atlassian.util.concurrent.Promise?

Here is my code:

final JiraRestClient client ;

final IssueRestClient issueClient = client.getIssueClient();

final Issue issue = issueClient.getIssue("TST-3").claim();

String str = "Wojtek";

final String filename1 = "my-test-file";

issueClient.addAttachment(issue.getAttachmentsUri(), new ByteArrayInputStream(str.getBytes("UTF-8")), filename1).claim();

final String filename2 = "my-picture.png";

final Issue issueWithAttachments = issueClient.getIssue("TST-3").claim();

Thank you. Your help is appreciated.

Thank you for the response. I've added the certificate to my keystore and that error seems to have gone away. Why does the following not work:

final JiraRestClientFactory clientFactory = new AsynchronousJiraRestClientFactory();

It erros and tells me to change type of JiraRestClientFactory.


What exact version of JRJC do you use? How does look your dependency in pom.xml? Do you have also dependency to older version of JRJC?

It looks like you have incorrect dependency in pom.xml, as the code above looks fine to me.

Hello Aleksander, your hint, how to get certificate from (cloud/hosted) JIRA server using openssl (instead of IE/Internet Options/Content/Certificates… export) save me. Thank you! Best regards, Roberto.

I.e. How to get certificates from a JIRA server instance in the Atlassian cloud: openssl s_client -connect -showcerts

what if I don't want / can't add a certificate to some specific server?

how can I force JIRA Rest client Java library to accept expired certificates? 

JRJC is great, I belive it uses customized Apache HTTP Client internally, why not externalize this dependency and give an option for the user to specify a HttpClient instance. That will add the capability of setting custom HttpClient with SSL Context in it, thereby allowing both static certificate configuration (via Keystore) as well as dynamic setting of required certificates.

Most of the companies hosts JIRA under HTTPS protocol and assigns private certificates for each users.


Ratheesh R Nair

Suggest an answer

Log in or Join to answer
Community showcase
Louis De Jaeger
Posted Thursday in Off-topic

Friday fun: your best joke

Hi all Lets make this Friday fun really fun and post one (or more) of your best jokes! The joke can be about an Atlassian product, or just a really fun joke you want to share! I’m not the best j...

190 views 12 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot