1. Pushparaj V
  2. PowerBuilder
  3. Monday, 9 September 2024 10:53 AM UTC

Hi 

 

We are trying to add OAuth Authentication in our Application, in my machine where the initial code was developed the authentication works fine, however when I share the code/Exe with team members in their machine it is not working, the first part to get Auth Code is working, but with this code to get the Token is not working.

When we try to mimic the same in Postman we are getting error: Self signed certificate in certificate chain

Tried with both HTTP client and Oauth Client.

We are using Authorization Code with PIKCE

PB Version: 2022R3.

Could anyone please help on this issue? What could be the issue, as it is working for me and not for him. TIA

Code Snippet:

//PostData
ls_PostData = "grant_type=authorization_code&client_id=" + ls_id + "&redirect_uri=" + ls_Redirect +"&scope=" + ls_Scope + "&code_verifier=" + ls_code_verifier + "&code="+ls_code
ll_return = lhc_Client.SendRequest( "POST", ls_Url, ls_PostData )
If ll_return = 1 And lhc_Client.GetResponsestatusCode() = 200 Then
lhc_Client.GetResponseBody ( ls_body )
ls_Error = ljpg_json.loadString ( ls_body )
If ls_Error = "" then
ls_TokenType = ljpg_json.GetValue("token_type")
ls_Token = ljpg_json.GetValue("access_token")
tab_1.Tabpage_2.token_type2.Text = ls_TokenType
tab_1.Tabpage_2.access_token2.Text = ls_Token

ls_AccessToken = ls_TokenType + " " + ls_Token

//Step 2: Get the RESTful server resource.
ls_Url = "https://xxxxxxxxxxxxxxxxxxxxxxxxx"
lhc_Client.ClearRequestHeaders()
lhc_Client.SetRequestHeader( "Authorization", ls_AccessToken )
ll_return = lhc_Client.SendRequest( "GET", ls_Url )
If ll_return = 1 And lhc_Client.GetResponsestatusCode() = 200 Then
lhc_Client.GetResponseBody ( ls_body )
mle_1.Text = ls_body
Else
mle_1.Text = "ResourceResponse Falied: "+ "Return :" + String ( ll_return ) + "~r~n" + lhc_Client.GetResponsestatusText()
End If

Else
mle_1.Text = "Error: "+ ls_Error
End If
Else
mle_1.Text = "AccessToken Falied: "+ "Return :" + String ( ll_return ) + "~r~n" + lhc_Client.GetResponsestatusText()
End If

 

Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Monday, 9 September 2024 16:40 PM UTC
  2. PowerBuilder
  3. # 1

Hi Pushparaj,

The error is most likely due to the fact that you are using a self-signed certificate for the authentication server. This is no problem when doing local development, because the self-signed certificate was added to your own certificate store, thus your authentication process goes OK. But other machines don't have your certificate, causing the error you see. You need to find the certificate that's being used, and share it with them so that they can add it to their certificate stores. I'm sorry I'm not quite knowledgeable as to know where to find it, or which store they should put it in; I just wanted to explain what's causing the error.

 

Regards,
Francisco

Comment
  1. Pushparaj V
  2. Thursday, 12 September 2024 11:01 AM UTC
Hi Rene, Maybe I am not understanding but please bear with me.

The few other machines where we tried we did not get any such popup or message to import certificate, we just ran the exe and it worked fine.

Also we did not get any certificate from server to install. Is there any option in PowerBuilder to do this via code?
  1. Helpful
  1. Francisco Martinez @Appeon
  2. Thursday, 12 September 2024 15:45 PM UTC
There's no function in PB to install certificates, you most likely need to do it manually.
  1. Helpful
  1. Pushparaj V
  2. Friday, 13 September 2024 16:59 PM UTC
One more find to add here, via postman when we hit the same auth and token URL with the setting "SSL Certificate Verification" then we are getting successful response, meaning we are able to get the token, however when the same setting is turned ON it is not working with the error " Self signed certificate in certificate chain".



Via PB code both with the setting turned on and off we are getting the same -1 return code.



Does anyone knows what could be the issue at system level? please guide.



  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 9 September 2024 11:02 AM UTC
  2. PowerBuilder
  3. # 2
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.