-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make-context #24
Make-context #24
Conversation
X509_STORE_CTX_get_error SSL_CTX_set_default_verify_dir SSL_CTX_set_default_verify_file SSL_VERIFY_* constants SSL_CTX_SET_VERIFY SSL_SESS_CACHE_* constants
af16f4f
to
1e33ff8
Compare
After a very superficial look: I think better name instead of
|
Actually it was I don't think cl+ssl:(make-)context is a good name for this particular function since there is always two contexts (SSL_CTX_new and SSL_ctx). And this naming can be confusing. |
No no, I think you probably forgetting (due to late hour?) your original, correct, reasoning. SSL_CTX_new and SSL_ctx are not two context. SSL_CTX_new creates new context, it can create one, two or as many contexts as we want. SSL_ctx is a slot of ssl session storing a context earlier created by SSL_CTX_new.
|
yeah you are right, any other thoughts? I'll change the name right now |
1e33ff8
to
9965085
Compare
done! |
#:+ssl-verify-none+ | ||
#:+ssl-verify-peer+ | ||
#:+ssl-verify-fail-if-no-peer-cert+ | ||
#:+ssl-verify--client-once+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two dashes - is it typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
We will also need to document new public API in the doc (index.html) |
Makes sense to add |
@deadtrickster do you think it would be convenient to have a |
9965085
to
b388740
Compare
@avodonosov (declaim (inline free-context))
(defun free-context (context)
(ssl-ctx-free context)) ?
documentation - news section is extremely outdated, as well as copyright years and holders btw :-) |
87a3079
to
3d37dfa
Compare
+ssl-verify-none+ +ssl-verify-peer+ +ssl-verify-fail-if-no-peer-cert+ :+ssl-verify-client-once+
3d37dfa
to
f440b3e
Compare
It's too much IMO. I don't wan't to hide real OpenSSL API, and introduce our different API. I think it's better to think of cl+ssl as a plain ffi bindings to OpenSSL + some helpers.
nil by default, or course, I fully agree. I wasn't sure about auto-free because it will complicate the invocation format of
Thanks. Yes, there are outdated parts, in particular I am considering to remove the news section to avoid maintenance. But not now. |
Well given that cl+ssl implements gray streams I don't think it is plain ffi + some helpers
I played with it and you know what? It can kill you if you'll try to reuse freed context (basically on sbcl at least you are done and have to restart sbcl)! And as you rightly assume contexts indeed intended to be long-lived I remember when we met last time on #lisp we agreed that cl+ssl actually has two parts - plain ffi bindings and a lot of helpers ;-). Or I misunderstood something? Lets make it clear now since next step I plan is actually introduce wrapper around ssl-ctx structure with which I can at least test if it was freed, initialized or not (as I said earlier it just kills entire lisp instance in case of an error). If you think it is too much then I'll continue to contribute ffi related-stuff (there is so much to do too) but all these highlevel things will go to my separate repo. |
Changed some defaults, added documentation |
63cb082
to
fe9ee5d
Compare
About #-asdf - I just googled how others do it. |
added (hopefully concise) documentation entry for |
Thank you very much for new features and for being so responsive during the review. It's a great contribution - enables many convenient use cases, while preserving backward compatibility. |
BTW, I forgot one important thing: do we use any new OpenSSL functions which present only in new versions of OpenSSL? (As I learned from your pull request #8, some features like verifying host/email/ip were absent in old OpenSSL and people needed to implement it themselves; later these features were added to OpenSSL). Do we now depend on some similar, newly introduced OpenSSL API? |
good question. recently a lot of stuff was deprecated and unfortunately openssl usually shipped very outdated. For example Now I don't think hostname verification should rely on openssl implementation. At least until we implement reliable openssl-version dependent switches. But even with these switches there is a great possibility of subtle difference between old-lisp and new-openssl implementations. I have battle-tested erlang implementation, I'll just backport it and cover with tests. |
I mean in this pull request, new functions we use, like
Doesn't your pull request #8 provide this? |
Yep my pull request provide this however it was tested and used by me only. While https://github.com/deadtrickster/ssl_verify_hostname.erl is widely used and therefore I can be sure in its algorithm and tests. |
Listen, I can't reproduce the verify-peer failure from examples in the description. Instead of the error I get normal HTTP reply:
|
I am trying on quicklisp 2015-09-24, CCL 1.9 on linux. |
Hmm at first I was thinking about my drakma patches, but: (cl+ssl:with-global-context
((cl+ssl:make-context :verify-mode cl+ssl::+ssl-verify-peer+))
(usocket:with-client-socket (socket stream "incomplete-chain.badssl.com" 443
:element-type '(unsigned-byte 8))
(let* ((ssl-stream (cl+ssl:make-ssl-client-stream stream
:hostname "incomplete-chain.badssl.com"))
(char-stream (flexi-streams:make-flexi-stream ssl-stream
:external-format '(:utf-8 :eol-style :crlf)))
(reply-buf (make-string 1000)))
(unwind-protect
(progn
(format char-stream "GET / HTTP/1.1~%")
(format char-stream "Host: incomplete-chain.badssl.com~%~%")
(finish-output char-stream)
(read-sequence reply-buf char-stream)
reply-buf)
(close ssl-stream))))) also signals
sbcl 1.3.1 on linux too |
This usocket example behaves the same for me |
ok let me install ccl too |
By "the same" I mean signals failre - "the same" as your result |
Only the drakma example differs - doesn't fail |
oh thank you :-) so looks like drakma issue. lets dive deeper into this when hostname verification merged |
Provides
with-global-context
macro andmake-context
functionCan help with problems like described here:
edicl/drakma#50
Examples: