IdHTTP1 - Error Connecting With SSL

Hi,

I'm trying to connect to google translate's API.  I'm running Delphi7 
and Indy 9.00.10.  When trying to connect with the code below I am
getting "Error connecting with SSL."  I have downloaded the
"libeay32.dll" and "ssleay32.dll" from indy.fulgan.com/SSL/Archive/.  I
have been researching this for some time and trying different settings
but no luck.  BTW, the code below connects fine using DelphiXE and the
version of Indy that comes with XE.  Unforunately I need it to work
with Delphi 7.  With the new google translate API you need a billable
account set up with I have.

Any ideas would be appreciated.

Thanks,

Dexter

Code

function TForm1.translate(ss,lng:string):string;
var s:widestring;
a,b:integer;
http:tidhttp;
sKey : String;
FSSL : TIdSSLIOHandlerSocket;
begin
  sKey := 'yourgooglekeygoeshere';
  http:=tidhttp.Create(nil);

  FSSL := TIdSSLIOHandlerSocket.Create(nil);
  HTTP.IOHandler := FSSL;

  s:=http.Get('https://www.googleapis.com/language/translate/v2?key='+sKey
  +'&source=en&target=de&q=Hello%20world');
  a:=posex('›',s,pos('‹textarea',s));
  b:=posex('‹/textarea›',s,a);
  result:=copy(s,a+1,b-a-1);
  http.Free;
end;

--
0
Dexter
9/15/2012 4:04:47 PM
embarcadero.delphi.winsock 1874 articles. 2 followers. Follow

3 Replies
5753 Views

Similar Articles

[PageSpeed] 36

Dexter McKenzie wrote:

 > I'm trying to connect to google translate's API.  I'm running Delphi7
 > and Indy 9.00.10.
....
 > but no luck.  BTW, the code below connects fine using DelphiXE and the
 > version of Indy that comes with XE.  Unforunately I need it to work
 > with Delphi 7.

The current Indy version (10.5.9) can be used with Delphi 7, either 
installed as packages or by adding the Indy source directories 
(Lib/Core, Lib/Protocols and Lib/System) to the project search paths.

Hope this helps
-- 
Michael Justin
0
Michael
9/15/2012 6:38:08 PM
Dexter wrote:

> I'm running Delphi7 and Indy 9.00.10.

The last version of Indy 9 was 9.0.50.

> When trying to connect with the code below I am getting "Error connecting 
with SSL."

You are not configuring any of the properties for TIdSSLIOHandlerSocket, 
so the defaults are likely not suitable for Google's requirements.  For example, 
the default value of the SSLOptions.Method property in Indy 9 is sslvSSLv2, 
but is sslvTLSv1 in Indy 10.  It is very rare that anybody uses SSL v2 nowadays.

Try this:

{code:delphi}
function TForm1.translate(ss,lng:string):string;
var
  s: String;
  a, b: Integer;
  http: TIdHTTP;
  sKey : String;
  FSSL : TIdSSLIOHandlerSocket;
begin
  sKey := 'yourgooglekeygoeshere';
  http := TIdHTTP.Create(nil);
  try
    FSSL := TIdSSLIOHandlerSocket.Create(http);
    FSSL.SSLOptions.Method := sslvTLSv1; // or sslvSSLv23, which is used 
as a wildcard for dynamic version negotiating...
    http.IOHandler := FSSL;

    s := http.Get('https://www.googleapis.com/language/translate/v2?key='+sKey+'&source=en&target=de&q=Hello%20world');
    a := PosEx('>', s, Pos('<textarea', s));
    b := PosEx('</textarea>', s, a);
    Result := Copy(s, a+1, b-a-1);
  finally
    http.Free;
  end;
end;
{code}

--
Remy Lebeau (TeamB)
0
Remy
9/17/2012 5:56:03 PM
Hi  Remy,

That works!  Thank you very much!

Dexter
0
Dexter
9/20/2012 7:56:21 AM
Reply:

Similar Artilces:

Delphi XE2 DataSnap SSL connection
Hi, I need to create Delphi XE2 DataSnap desktop application working over internet. So I want to use SSL encryption for communication between server and clients with public and private key. Server must accept connections only with proper SSL key ( datasnap server must check this ). And I have questions: 1. Which is better protocol for this - HTTPS or TCP/IP with encryption filters? 2. Can I see somewhere example how to do this with SSL public and private key, because I can not find such example? Thanks in advance, Ivan ...

Delphi XE and Indy SSL connection with trusted certificate [Edit]
Hi, In the procedure *TIdSSLContext.InitContext(CtxMode: TIdSSLCtxMode)*; (IdSSLOpenSSL.pas) Lines {code} // CA list if RootCertFile <> '' then begin {Do not Localize} SSL_CTX_set_client_CA_list(fContext, IndySSL_load_client_CA_file(RootCertFile)); end{code} In the function *IndySSL_load_client_CA_file(const AFileName: String): PSTACK_OF_X509_NAME;* The second time through the loop {code}while (PEM_read_bio_X509(LB, @LX, nil, nil) <> nil) do begin{code} raise an exception (EAccessViolation in libeay32.dll) when my RootCertFile have more than ...

I am Installing GWMobile 3.01 In the portion for SOAP configuration on the POA, since I want to use a SSL Connection Can I change the SOAP SSL to Enable and Not interrupt the connection for our existi
--____RFCKOFBDHFBBWJKUFDIF____ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: base64 Content-Disposition: inline; modification-date="Tue, 8 Jun 2009 10:12:14 -0400" SSBhbSBJbnN0YWxsaW5nIEdXTW9iaWxlIDMuMDEgSW4gdGhlIHBvcnRpb24gZm9yIFNPQVAgY29u ZmlndXJhdGlvbiBvbiB0aGUgUE9BLCBzaW5jZSBJIHdhbnQgdG8gdXNlIGEgU1NMIENvbm5lY3Rp b24gQ2FuIEkgY2hhbmdlIHRoZSBTT0FQIFNTTCB0byBFbmFibGUgYW5kIE5vdCBpbnRlcnJ1cHQg dGhlIGNvbm5lY3Rpb24gZm9yIG91ciBleGlzdGluZyBCbGFjayBCZXJyeSBzZXJ2ZXIgdGhhdCBp cyB1c2luZyBTT0FQPw0KU2hvcnQgVmVyc2lvbi4uLi4uV2hlbiB1c2luZyBTT0FQIGlzIGFsbCBj b21td...

SSL connection?
I've signed up with a webhosting service that says they offer SSL connections for their customers (that of course, being me).. So, if I want to send users on my website to an address that is secure (using SSL)... do I just need to send users to the page on my site, only changing the http:// to https:// for example, assuming this is a function in my CodeBehind... would this work? // button click protected void btnProceedToCheckOut_OnClick(object sender, System.EventArgs e) { Response.Redirect("https://www.mydomain.com/checkout.aspx"); } will that ...

Winsock and SSL
Hi, I am using the winsock.pbl in order to use them in my aplication. I want to use it as a POP3 client with SSL, but I am not finding for SSL. How can I connect to a POP3 server with SSL? Thanks S. Convalle What are you trying to do? I had to do a lot of work with the windows api calls and winsock.pbl a while back at a client. I assume it's the same thing you're talking about. Was this a shareware pbd built back in 95-96 timeframe? What I discovered is that doing socket communications is MUCH EASIER with Java and then using PBNI to go from PB-Java. Just ...

SSL to no SSL
Hi I have install GW6.0.4 webaccess with SSL and my question is. Can I turn off SSL and use port 80? /matts Matts Sehlberg wrote: > I have install GW6.0.4 webaccess with SSL and my question is. > Can I turn off SSL and use port 80? SSL or the lack thereof has nothing to do with webaccess itself, and everything to do with the web server you're running it on. You should just be able to point the browser at http://<server>/servlet/webacc instead of https://<server>/servlet/webacc -- Jim NSC SYsop Ok I try that on Friday /Matts "J...

not connected when I am connected
What do I need to change on my 'puter when the icon in the toolbar shows and tells me I am connected and the error message tells me I am not and I can not go to web pages, get or send emails. I have to close down and restart to get connected again. This only happens if I am on line and leave the 'puter for an hour or so. As long as I am using it I don't have a problem. This just started about a month ago. I am on very slow dialup, DSL and Cable not in my area, thanks you SBC/ATT tks Elaine wrote: > What do I need to change on my 'puter when the icon in ...

NO SSL to SSL
I have a system with webaccess. I have followed the following TID 10016636 but when I click on the .../servlet/webacc link, I get a bad gateway. When I comment out the solution from the TID and restart APACHE, I'm back up and running. What am I doing wrong? I am using APACHE for my webserver. Is there a step by step for setting up SSL for webaccess? I have tried and tried but cannot seem to get it working with SSL. I have also tried to enable it on the webaccess agent within ConsoleOne but that hasn't worked either. Other info: NW6.0sp3 GW6.5sp1 (web access is ...

SSL connections
Scenario: a) server 1 - OES Linux with eDir881, installed IDM vault and AD driver (mode - connect to remote loader) b) server 2 - Windows 2003 with eDir881, installed remote loader and AD driver. Both servers in the same tree. Question 1: for SSL connection between IDM engine and remote loader I must create server certificate (used for connection string) and export self-signed CA certificate. For server certificate - what server I need select in "Create Server Certificate wizard" (Linux box or Windows server? Question 2: for SSL connecti...

SSL connections
Hi, I'm configuring ASE 12.5x for using SSL, does Sybase server prevent non-SSL connections? Thanks! ~Luis ...

winsock connection
Is there a way to open a Winsock connection in PB5? If so can you direct me to some examples of code that does this? If this cannot be done is there a way to have PB5 read and write E-Mail messages and to have a triggered event occur when a specific E-Mail message is encountered? Thanks in advance, Patrick In article <ROoV4ydK#GA.81@forums.powersoft.com>, pburcky@compuserve.com says... > Is there a way to open a Winsock connection in PB5? If so can you direct me > to some examples of code that does this? If this cannot be done is there a > way to have PB5 read...

Connect with Delphi
Does anyone know a way to get a native connection with Delphi to SQL-AnyWhere 5.5? ODBC is to slow and indexes, references cannot be seen. Any comments will be appreciated Frank Steinmann FrankSteinmann@t-online.de I believe the BDE is slow using ODBC. People who use ODBCExpress (www.odbcexpress.com) with SQL Anywhere say it is fast. ODBCExpress is a VCL only way of accessing ODBC databases. Hope this helps Mike Frank, The only "Native" connection that I know of is through Titan's VCL components. These use API calls instead of ODBC. I have exp...

SSL or Not SSL
Hi, I currenty am in the middle of developing a web application that is run under https. What I want to do is as follows: 1) Login page to run under HTTPS. 2) Once logged in redirect to main site running under HTTP. The problem I feel am going to encounter is that due to the fact Im using 2 sites is how to get the authentication details between the 2 sites Is there a recognised technique for doing this and if this is the case can anyone point me in the direction of a tutorial to do this? Best wishes Stuart Unless you designate a site can't be accessed withou...

SSL connection
Dear Fellow friends, need your help on guiding me towards connecting asp.net with SSL connection. I tried to read up from www.verisign.com site to get the idea, but there are still codes problems of connecting.Does anyone have any idea of getting the codes? thanks! Would this link help?: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/secnetht19.asp thanks, lauraThis posting is provided "AS IS" with no warranties, and confers no rights. Thanks for the site but i still dun understand. I had got the cert from verisign but i don't know how to link my ...

SSL connection
What do I need to do to stop getting the message on the WA console "Client failed to connect via SSL" Thanks Seb Sebastian Cerazy wrote: > "Client failed to connect via SSL" Did you enable SSL for the WebAccess agent? Kinda sounds like it - this would mean that the WebAccess agent is trying to talk to the POA via SSL. -- Danita Zanre Novell Support Forums Volunteer http://www.caledonia.net/iris.html Kind of obvious (if you know what to look for) Thanks Danita Seb "Danita Zanre" <danita@no-spam-caledonia.net> wrote i...

superreview granted: [Bug 185662] In SMTP prefs, make it clear what "use secure connection (SSL)" really means : [Attachment 162528] updated version of STARTTLS/SMTP-over-SSL patch
David Bienvenu <bienvenu@nventure.com> has granted Nelson Bolyard <nelson@bolyard.com>'s request for superreview: Bug 185662: In SMTP prefs, make it clear what "use secure connection (SSL)" really means https://bugzilla.mozilla.org/show_bug.cgi?id=185662 Attachment 162528: updated version of STARTTLS/SMTP-over-SSL patch https://bugzilla.mozilla.org/attachment.cgi?id=162528&action=edit ------- Additional Comments from David Bienvenu <bienvenu@nventure.com> we need to make sure this doesn't overflow the dialog because of the longer string (STA...

superreview requested: [Bug 185662] In SMTP prefs, make it clear what "use secure connection (SSL)" really means : [Attachment 162528] updated version of STARTTLS/SMTP-over-SSL patch
Nelson Bolyard <nelson@bolyard.com> has asked David Bienvenu <bienvenu@nventure.com> for superreview: Bug 185662: In SMTP prefs, make it clear what "use secure connection (SSL)" really means https://bugzilla.mozilla.org/show_bug.cgi?id=185662 Attachment 162528: updated version of STARTTLS/SMTP-over-SSL patch https://bugzilla.mozilla.org/attachment.cgi?id=162528&action=edit ...

SSL Connect To LDAP
Hello. I have a Delphi program that is trying to connect to LDAP on port 636 hosted by Netware 6.5. I get a "Server Down" error from Microsoft's winldap.h Just a note, everything works fine when I connect using java over SSL. Here is the DSTRACE: TLS accept failure 5 on connection 0xbf9dae00, setting err = -5875. Error stack: TLS handshake failed on connection 0xbf9dae00, err = -5875 Here is the TCP trace (10.10.1.190 is the client, 10.10.1.70 is the server): No. Time Source Destination Protocol Info 9 2.814087 10.1...

OID SSL Connection
--____CMKNNBAISOJVTTYYSLJF____ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: base64 Content-Disposition: inline; modification-date="Thu, 16 Aug 2006 16:37:25 +0200" SGksDQoNCldlIGFyZSB1c2luZyB0aGUgT0lEIERyaXZlciB0byBjb25uZWN0IHRvIGFuIE9yYWNs ZSBzeXN0ZW0uIFdlIGhhdmUgdG8gY29ubmVjdCB2aWEgU1NMIChub24gLVNTTCB3b3JrcyBmaW5l ISkuIA0KU28gd2UgY3JlYXRlZCBhIGVXYWxsZXQgaW4gdGhlIE9JRCBhbmQgZXhwb3J0ZWQgdGhl IGZpbGVzIChlV2FsbGV0LnNzbyBhbmQgZVdhbGxldC5wMTIpIHRvIGEgZGlyZWN0b3J5IG9uIG91 ciBMaW51eCBPRVMgQm94IHdoZXJlIElETTMgaXMgcnVubmluZy4NCg0KSWYgd2UgdHJ5IHRvIHN0 YXJ0...

Winsock TCP Connections..
Thanks in Advance.. I don't have any experience in tcp conectivity but I need to make a small aplication that can be listening to a IP and Port The requerement's are that this aplication can be in a server receiving information from over 700 concurrent connections all using the same port, so I need to open a Socket for each conection that is coming, receive then data and wait for more data, after 1 hour of no activity or data comming, I need to close the connection and release the socket for furder incomming connections. I already downloaded a n_winsock sample but seems to work only with one concurrent connection. Any Idea or Sample code... Thanks Again... LMCM On Aug 31, 11:31=A0am, "Lmcm" <lcava...@cercadonet.com.mx> wrote: > Thanks in Advance.. > > I don't have any experience in tcp conectivity but I need to make a small > aplication that can be listening to a IP and Port > > The requerement's are =A0that this aplication can be in a server receivin= g > information from over 700 concurrent connections > all using the same port, =A0so I need to open a Socket for each conection= that > is coming, =A0receive then data and wait for more data, =A0after 1 hour o= f no > activity or data comming, =A0I need to close the connection and release t= he > socket for furder incomming connections. > > I already downloaded a =A0n_winsock =A0sample but seems t...

SSL connection issues
From everything that I have read, I really shouldn't have to do anything different when doing a HTTPS Post compared to a HTTP Post.  Unfortunatelly, I keep getting an error when I try the HTTPS Post.  My first impression was that the Certificate was not placed in the proper store but I have since verified that it is there.  Here is my test code as I was tired of re-writing my entire page, I created a test HTTPS that just does a ping onto the box that I'm trying to attach to.  This works from my browser on the same machine so I figured that it would be a good test.<scri...

Where is 3DES from SSL connections?
Just tought about it...I have NEVER being in a website that uses 3DES in the SSL. All use RC4 with 128bits. Is there a good reason for this one (besides that 3DES is slow) or to be honest, is there a single page in www that uses 3DES in the SSL/TLS? Ofcourse it doesnt matter much since they all offer 1024bit RSA so who cares, but stil I wonder... -- Markus Jansson ************************************ My privacy related homepage and PGP keys: http://www.geocities.com/jansson_markus/ ************************************ "Markus Jansson" <jansson_markus@zipli...

Winsock or connection object
I want to use winsock or connection object to login to UNIX machine and make some unix commands and send the results or files to powerbuilder again. How can i make it !? ...

Multiple SSL connections?
In the Net::LDAPS manpage BUGS section there's this ... "You cannot have more than one LDAPS connection at any one time, due to restrictions in the underlying Net::SSLeay code." I've come across a case where I'd really like to query two separate servers, both with secure connections. (I can't easily query them in batches.) Does this limitation apply to using Net::LDAP's start_tls? Does someone know what "at any one time" means. Perhaps one of these? - Don't even instantiate two separate objects at the same time - Don't...

Delphi Connection Issue?
I am creating a new ASE 11.9.2 on NT. This server will be used with a Borland Delphi client. In the past we have always named our ASE the same as the server/network name. So, for ex, the box is named server1 and the ASE is named server1. Now we want to name the box serverxx and the ASE on box serverxx something else, for example asexx. This works fine with creating ASE, just using the defaults. I can also connect via SQL Advantage with no problem. However, I can't get the BDE Delphi administrator to connect to ASE. Does anyone have any ideas? Is this even feasibl...