Rest connection cert issues

206 views
Skip to first unread message

Kyle Nelson

unread,
Nov 19, 2020, 5:05:42 PM11/19/20
to COZYROC
I'm getting the lovely error at the bottom of this post when I try to test my REST connection to Jira.  I am pretty sure it has something to do with the Cert, but I've tested the cert with the sample Java project that's linked in the help file and it worked just fine.

I'd appreciate any advice you have.








===================================

Validating connectivity via endpoint `/myself` failed. Details:

Cannot find the requested object.
 (CozyRoc.SSISPlus.2019)

------------------------------
For help, click: https://www.cozyroc.com/form/exception?v=2.0.100.1735&sql=2019&vs=16.8.30711.63&err=System.Exception%3A%20Validating%20connectivity%20via%20endpoint%20%60%2Fmyself%60%20failed.%20Details%3A%0D%0A%0D%0ACannot%20find%20the%20requested%20object.%0D%0A%20---%3E%20System.Security.Cryptography.CryptographicException%3A%20Cannot%20find%20the%20requested%20object.%0D%0A%0D%0A%20%20%20at%20System.Security.Cryptography.CryptographicException.ThrowCryptographicException%28Int32%20hr%29%0D%0A%20%20%20at%20System.Security.Cryptography.X509Certificates.X509Utils._QueryCertFileType%28String%20fileName%29%0D%0A%20%20%20at%20System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile%28String%20fileName%2C%20Object%20password%2C%20X509KeyStorageFlags%20keyStorageFlags%29%0D%0A%20%20%20at%20System.Security.Cryptography.X509Certificates.X509Certificate2..ctor%28String%20fileName%2C%20String%20password%29%0D%0A%20%20%20at%20binder_for_System.Security.Cryptography.X509Certificates.X509Certificate2..ctor%28ScriptEngine%20%2C%20Object%20%2C%20Object%5B%5D%20%29%0D%0A%20%20%20at%20Jurassic.Compiler.Binder.Call%28ScriptEngine%20engine%2C%20Object%20thisObject%2C%20Object%5B%5D%20arguments%29%0D%0A%20%20%20at%20Jurassic.Library.ClrStaticTypeWrapper.ConstructLateBound%28Object%5B%5D%20argumentValues%29%0D%0A%20%20%20at%20Jurassic.Library.FunctionInstance.ConstructWithStackTrace%28String%20path%2C%20String%20function%2C%20Int32%20line%2C%20Object%5B%5D%20argumentValues%29%0D%0A%20%20%20at%20anonymous%28ScriptEngine%20%2C%20Scope%20%2C%20Object%20%2C%20FunctionInstance%20%2C%20Object%5B%5D%20%29%0D%0A%20%20%20at%20Jurassic.Library.UserDefinedFunction.CallLateBound%28Object%20thisObject%2C%20Object%5B%5D%20argumentValues%29%0D%0A%20%20%20at%20Jurassic.Library.FunctionInstance.CallWithStackTrace%28String%20path%2C%20String%20function%2C%20Int32%20line%2C%20Object%20thisObject%2C%20Object%5B%5D%20argumentValues%29%0D%0A%20%20%20at%20anonymous%28ScriptEngine%20%2C%20Scope%20%2C%20Object%20%2C%20FunctionInstance%20%2C%20Object%5B%5D%20%29%0D%0A%20%20%20at

------------------------------
Program Location:

   at CozyRoc.Rest.Connection.SendTestRequest()
   at CozyRoc.SqlServer.SSIS.RestConnectionManagerForm.#=zOY8qEdu2UgXPtRt18A==(Object #=zwK6bnMA=, EventArgs #=z4kOAHYU=)

===================================

Cannot find the requested object.
 (mscorlib)

------------------------------
Program Location:

   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
   at System.Security.Cryptography.X509Certificates.X509Utils._QueryCertFileType(String fileName)
   at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags)
   at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)
   at binder_for_System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(ScriptEngine , Object , Object[] )
   at Jurassic.Compiler.Binder.Call(ScriptEngine engine, Object thisObject, Object[] arguments)
   at Jurassic.Library.ClrStaticTypeWrapper.ConstructLateBound(Object[] argumentValues)
   at Jurassic.Library.FunctionInstance.ConstructWithStackTrace(String path, String function, Int32 line, Object[] argumentValues)
   at anonymous(ScriptEngine , Scope , Object , FunctionInstance , Object[] )
   at Jurassic.Library.UserDefinedFunction.CallLateBound(Object thisObject, Object[] argumentValues)
   at Jurassic.Library.FunctionInstance.CallWithStackTrace(String path, String function, Int32 line, Object thisObject, Object[] argumentValues)
   at anonymous(ScriptEngine , Scope , Object , FunctionInstance , Object[] )
   at Jurassic.Library.UserDefinedFunction.CallLateBound(Object thisObject, Object[] argumentValues)
   at Jurassic.Library.FunctionInstance.CallWithStackTrace(String path, String function, Int32 line, Object thisObject, Object[] argumentValues)
   at anonymous(ScriptEngine , Scope , Object , FunctionInstance , Object[] )
   at Jurassic.Library.UserDefinedFunction.CallLateBound(Object thisObject, Object[] argumentValues)
   at CozyRoc.Rest.Connection.#=zlOC0NSGszkKs(String #=zR1ylq$w=, String #=zOGZ515diyNRk, Object[] #=zRE3r$rE=)
   at CozyRoc.Rest.Connection.EvaluateTemplate[T](String #=zR1ylq$w=, Hashtable #=zA$FS_Ww=)
   at CozyRoc.Rest.Connection.SetupRequestParameters(IRestRequest #=z0J$U9rI=, RestParameter[] #=zNWw5lbEQ6C3a, Hashtable #=zEF4siJ_oVJr$)
   at CozyRoc.Rest.Connection.#=zGEE0z7fDFmvy(IRestRequest #=z0J$U9rI=)
   at CozyRoc.Rest.Connection.Authenticator.Authenticate(IRestClient #=zwvJ5yw0=, IRestRequest #=z0J$U9rI=)
   at RestSharp.RestClient.Execute(IRestRequest request, String httpMethod, Func`3 getResponse)
   at RestSharp.RestClient.Execute(IRestRequest request)
   at CozyRoc.SqlServer.SSIS.RestClientEx.Execute(IRestRequest #=z0J$U9rI=)
   at CozyRoc.Rest.Connection.ExecuteRequest[T](IRestRequest #=z0J$U9rI=, Boolean #=z4wXEQIQ=)
   at CozyRoc.Rest.Connection.SendTestRequest()

Ivan Peev

unread,
Nov 20, 2020, 5:13:59 PM11/20/20
to COZYROC
Hi Kyle,

What is the file extension of the certificate file you are trying to use?

Kyle Nelson

unread,
Nov 20, 2020, 6:36:00 PM11/20/20
to COZYROC
I've tried with both a .pem and .pcks8 file, both have the same contents which is structured like this:

-----BEGIN PRIVATE KEY-----
(full string of the private key in here)
-----END PRIVATE KEY-----


Kyle Nelson

unread,
Nov 20, 2020, 6:49:05 PM11/20/20
to COZYROC
Also, I just tried using the rsa.pem that comes with the sample project to see if there is any difference in the outcome and it gives the same error trying to generate the cozy roc token xml file.

Ivan Peev

unread,
Nov 21, 2020, 5:10:32 PM11/21/20
to COZYROC
Kyle,

Please provide the certificate file in pfx format.

Kyle Nelson

unread,
Nov 23, 2020, 8:47:07 AM11/23/20
to COZYROC
Ok, I got it to go past that part.  Now when I specify the .pfx certificate it attempts to do the handshaking and gives an error saying it can't retrieve the token.

Oauth token error..png

If I ignore the error and login, I get the option to approve it, if I click "allow" then visual studio hard locks up.

If I copy that URL out and go to the URL itself I can paste it in and approve it, then it returns with a 404 error.

If I go to:


I can see that the token was approved, but if I use the oauth token listed in the URL as the connection and refresh token to create the .xml file that Cozyroc uses, when I do a test I get a "toke_rejected" error.

So, I think I'm closer I'm just still getting errors with the token itself now. 

Kyle Nelson

unread,
Nov 23, 2020, 10:06:33 AM11/23/20
to COZYROC
  Ok, got it to work!

Here's the steps.

Run VS as administrator 

 

 

Open a browser, login to atlassian/jira (might not be necessary) 

 

View > Other Windows > Web Browser (uses IE11 inside of visual studio) 


After logging in you can leave that window open. 

 

Add a new connection Rest connection: 


Configuration: Jira 

Authentication: Oauth 

 

Click in the token file field, and then select New 


Browser Engine: Internet Explorer 

ConsumerKey: OauthKey 

Certificate:   click the browse button on the right. 


Browse to the .pfx formatted certificate:  


Click Next 

 

On the next screen click "Allow"  when asked to approve the cert. 

 

You'll be taken to a new screen with the Access Token filled out for you.  Leave everything above the middle dividing line alone. 

 

Browse to a location to save the file, and give it a password (required) 


Test should be successful.


Reply all
Reply to author
Forward
0 new messages