[squeak-dev] Combining SqueakSSL and SMTPClient?
Bernhard Pieber
bernhard at pieber.com
Tue Oct 5 21:16:56 UTC 2010
Dear fellow Squeakers,
I want to connect to an SMTP server which is secured by using SSL from Squeak, in fact the MobileMe SMTP server.
I thought this might be a good use case for SqueakSSL. I installed it on my Mac. I think it works, see http://lists.squeakfoundation.org/pipermail/squeak-dev/2010-October/154203.html.
I use the following code:
| smtp |
smtp := SMTPClient new.
smtp user: 'myname'.
smtp password: 'mypassword'.
[smtp openOnHost: (NetNameResolver addressForName: 'smtp.me.com' timeout: 20) port: 465.
smtp mailFrom: 'myname at me.com'
to: 'myself at example.com'
text: 'Hello from Squeak''s SMTPClient'.
smtp quit] ensure: [smtp close].
My first question: Is SecureSocketStream from SqueakSSL-Core polymorphic to SocketStream which is used in SMTPClient's stream inst var? See ProtocolClient>>ensureConnection.
I tried to replace it with a SecureSocketStream in my own SecureSMTPClient subclass. That alone does not work. I kind of guessed that because at least a handshake will very probably be needed.
Then I looked at WebClient>>sslConnect as an example and tried to do something similar in my subclass:
ensureConnection
| sqSSL |
self isConnected
ifTrue: [^self].
self stream
ifNotNil: [self stream close].
self stream: (SecureSocketStream openConnectionToHost: self host port: self port).
sqSSL := Smalltalk at: #SqueakSSL ifAbsent:[self error: 'SqueakSSL is missing'].
"Convert the stream to a secure stream"
self stream: (sqSSL secureSocketStream on: stream socket).
"Do the SSL handshake"
stream sslConnect.
"And cert verification"
stream verifyCert: self serverName.
self checkResponse.
self login
This still does not work. I get ConnectionTimedOut: Cannot connect to 17.148.17.61:465.
At this point I thought I might ask here. Has anyone done this already maybe? What could I try next?
Cheers,
Bernhard
More information about the Squeak-dev
mailing list
|