googleads / googleads-java-lib

Google Ad Manager SOAP API Client Library for Java
Apache License 2.0
226 stars 360 forks source link

Certificate Issue #205

Closed Sangita865 closed 10 months ago

Sangita865 commented 4 years ago

I have test account and I have downloaded the Google Ads certificate from the test account it is working fine with the test account.

But when I tried the same certificate with the different account it started giving me the below exception. Do the certificate depends on the account? if No can you please suggest something to resolve the below issue facing while creation of AdwordsSession.

unable to find valid certification path to requested targetat sun.security.ssl.Alerts.getSSLException(Alerts.java:198)at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1976)at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:318)at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:312)at sun.security.ssl.ClientHandshaker.checkServerCerts(ClientHandshaker.java:1846)at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1655)at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:260)at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1086)at

nwbirnie commented 4 years ago

Are you running with -Djavax.net.ssl.trustStore=...? If so could you verify that you have imported the correct certificate by running keystore -list please?

A quick test suggests that you should see something like this:

$ keytool -list -keystore test.keystore 
Enter keystore password:  
Keystore type: JKS
Keystore provider: SUN

Your keystore contains 2 entries

adwords.google.com, Sep 25, 2020, trustedCertEntry, 
Certificate fingerprint (SHA-256): 26:04:BD:94:AA:5F:35:DB:98:D3:72:9F:CB:19:A3:C1:C9:FE:6D:3A:B4:15:6D:48:A7:11:C8:CA:6C:87:79:FE
googleads.googleapis.com, Sep 25, 2020, trustedCertEntry, 
Certificate fingerprint (SHA-256): 3D:93:69:4D:73:31:7C:2D:78:F2:E6:25:D1:E2:DE:01:86:9D:39:F8:98:1A:E6:D0:4A:CC:93:F0:DB:91:F5:80
Sangita865 commented 4 years ago

Hi Nick,

Thanks for the quick response. Actually I have downloaded the certificate from the test account and it is working fine with test account credential, as client didn't share production account certificate with us as of now, so we are trying to use test account certificate with the production account. as per my understanding this is something related to domain. Do we require production certificate for this.

Thanks! Sangita

nwbirnie commented 4 years ago

There should be no difference between the certificates by account - the API endpoint is adwords.google.com for both test and production accounts. Can you confirm how you downloaded the certificate?

Sangita865 commented 4 years ago

Hi Nick,

For the certificate ->

  1. I clicked on view site Information(lock) on the adwords.com site
  2. Under the View Site Information, clicked on the certificate link
  3. Clicked on the Details tab.
  4. Clicked on the copy to file button.
  5. Pressed Next.
  6. Checked radio button of .DER Encoded binary file checkbox.
  7. Then browsed the file name and export it.
  8. Added the certificate using keytools java settings.

Do we require any other certificate for this to make it run?

Thanks! Sangita

nwbirnie commented 4 years ago

It's possible that you've got the wrong certificate - the address is adwords.google.com - viewing adwords.com in the browser will redirect you to ads.google.com.

Can you retrieve the certificate on the command line with OpenSSL? This would look like:

openssl s_client -connect adwords.google.com:443
<headers>
-----BEGIN CERTIFICATE-----
<copy this part to a new file>
-----END CERTIFICATE-----
<trailers>

Then you just need to copy the part between BEGIN CERTIFICATE and END CERTIFICATE to a new file and run keytool -importcert.

christopherseeley commented 10 months ago

AdWords API has been turned down and replaced by the Google Ads API. Closing as stale.