It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

1 vote
Answer 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 Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Expose your beautifully crafted Dashboard through the Jira Service Desk Customer Portal

  A picture is worth a thousand words, especially when you're trying to find relationships and understand your data. Here, Dashboards play a vital role in gaining insights from a variety of dat...

215 views 3 4
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you