Re: Using the SSL module.
Chris Angelico <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CAPTjJmownp0L6zowORRYLxED4hbSxEgHbA1o60cvxfir_XppDw@mail.gmail.com> |
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()); 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. ChrisA