Re: Using the SSL module.
Henrik Grubbström <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CALuAYvZtfZJY0nOwxWbRTGAE4Yqbn9qqdzzU5L6zqdQ2N4hpfw@mail.gmail.com> |
On 21 Jun 2015 16:43, "Chris Angelico" <[email protected]> wrote: > > On Mon, Jun 22, 2015 at 12:34 AM, Trilok Tourani > <[email protected]> wrote: > > Can someone please tell me as to how to make a connection between a server > > and a client, SSL protected? > > > > I have tried using SSL.sslfile(Stdio.File demo, SSL.context ctx) function > > but still don't understand how to make the data going through the connection > > encrypted/decrypted. > > Once you've done that, you don't read or write anything on the > underlying Stdio.File, you just use the SSL file. Anything you write > gets encrypted and then sent to the other end; everything you read has > first been decrypted. Generally, you can pretend that it's exactly the > same as a regular Stdio.File, although the abstraction leaks sometimes > (certain operations involve both reading and writing, even though you > wouldn't expect them to). > > If you're building the server in Pike, you'll need to set up a key and > certificate. Otherwise, it's fairly easy: > > int main() > { > Stdio.File sock = Stdio.File(); > sock->connect("gideon.rosuav.com", 443); > SSL.File ssl = SSL.File(sock, SSL.Context()); Note that with Pike 8.0 and later I believe that you need to also call ssl->connect("gideon.rosuav.com") here. > ssl->write("GET / HTTP/1.0\r\n\r\n"); > write("Response:\n%s\n", ssl->read(1024,1)); > } > > Although you seem to be using a version of Pike that has SSL.sslfile > rather than SSL.File, but translate as appropriate. Caveat emptor. /grubba