<sdogruyol>
why do i need to patch Context? It seems pretty ok to me
<jhass>
oh you think chain should include the end entity? mmh
<jhass>
SSL_CTX_use_certificate_chain_file() loads a certificate chain from file into ctx. The certificates must be in PEM format and must be sorted starting with the
<jhass>
subject's certificate (actual client or server certificate),
<jhass>
sounds good indeed, nvm
<sdogruyol>
well
<sdogruyol>
i dont have any intermediate ca or so
<sdogruyol>
just a .cer which contains everything
<jhass>
weird that the order is the other way around than usually here
<jhass>
which is a String (crystal will convert it automatically)
<jhass>
and that string should contain a path to a file
Raimondii has joined #crystal-lang
<sdogruyol>
yeah it does
<sdogruyol>
removed to_slice and it works no difference
Raimondi has quit [Ping timeout: 240 seconds]
<jhass>
sdogruyol: of course you also have to set the private key
Raimondii is now known as Raimondi
<sdogruyol>
actually there’s not a private key
<sdogruyol>
i use ssl_verify_mode :none in Ruby :P
<jhass>
wait, this isn't for TLS client auth?
<jhass>
but rather validating the server certificate?
<sdogruyol>
well it’s backend to backend
<sdogruyol>
kinda weird
<jhass>
that's not a well defined term in TLS
<sdogruyol>
:)
<jhass>
let's try to stay on terminology in order to not confuse ourselves and each other
<sdogruyol>
okay
<sdogruyol>
so i dont have private key
<jhass>
what do you want to do
<sdogruyol>
and i use ssl_verify_mode :none
<sdogruyol>
i want to make a SOAP request with this certificate
<jhass>
authenticate that the servers certificate is (indirectly) signed by a specific CA certificate
<jhass>
or send a client certificate to the server
<jhass>
it sounds like the former
<sdogruyol>
yeah i think so
<sdogruyol>
so how would i send this certificate to server so that it authorizes me to do SOAP calls :)
<sdogruyol>
that’s the problem
<sdogruyol>
i monkey patched context to accept the certificate but seems like it’s not going with the request
<jhass>
you're contradicting yourself again
<jhass>
you say the former but then go on with "sending a certificate to the server"
bjz_ has quit [Ping timeout: 246 seconds]
bjz has joined #crystal-lang
<jhass>
if you want to add a new CA certificate for validation, it seems to be SSL_CTX_load_verify_locations or SSL_CTX_set_cert_store
<jhass>
I believe the latter is the older/better supported API, at least more broadly used
<jhass>
but then SSL_CTX_set_cert_store recommends using SSL_CTX_load_verify_locations
pawnbox has quit [Remote host closed the connection]
dhk has joined #crystal-lang
matp has joined #crystal-lang
<sdogruyol>
seems like OpenSSL::SSL::Context is missing those right?
<jhass>
yup
<sdogruyol>
i need to take a look at LibSSL bindings then
<sdogruyol>
SSL_CTX_set_cert_store this seems like it
<jhass>
read the manpage, it recommends SSL_CTX_load_verify_locations
<jhass>
and that one takes filepaths
<sdogruyol>
:/
<jhass>
while with SSL_CTX_set_cert_store you first need to get it with SSL_CTX_get_cert_store, then manipulate it with SSL_CTX_set0/1_* which are all just macros
<jhass>
so you can't bind to them
<jhass>
so more useful for transporting the settings of one context to another
<sdogruyol>
can i monkey patch a lib like LibSSL?
<jhass>
sure
<sdogruyol>
let’s see if i can bind to SSL_CTX_load_verify_locations
<sdogruyol>
ouch just got an Invalid Memory Access :P
trapped has quit [Read error: Connection reset by peer]
trapped has joined #crystal-lang
<travis-ci>
crystal-lang/crystal#f8e0568 (release/0.17 - Compiler: improve error when using Class and other non-allowed types for instance/class/global vars. Fixes #2605. Fixes #2604): The build was broken. https://travis-ci.org/crystal-lang/crystal/builds/132607685
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
kfpratt has quit [Remote host closed the connection]
kfpratt has joined #crystal-lang
jmg_ has joined #crystal-lang
ryanw-se has joined #crystal-lang
<jmg_>
Hey everyone- working on a small project in Crystal that's working with a lot of interestingly formatted JSON data. In particular there is a field that is a mixed type array. Example: https://play.crystal-lang.org/#/r/zeq I've come across this Github issue (https://github.com/crystal-lang/crystal/issues/1061) which potentially gives me a path forward; however, I'm curious if there's an alternate solution that doesn't involve JSO
<jhass>
IRC has a length limit, cut off at "involve JSO"
<ryanw-se>
I'm trying to generate a fibonacci sequence up to a certain size (in this case 9), I'm starting out with an empty array with two entries [0, 1]
<ryanw-se>
when I generate the fibonacci sequence, when it gets to the index 0, it seems to believe that there is a 1 that comes before that index, ex [1, 0, 1]
<ryanw-se>
when I do the opposite [1, 0] (for testing purposes), it correctly identifies the index before 1 as 0
<jhass>
-1 gets the last element
<ryanw-se>
jhass: why would it identify [0, 1] as -> [1, 0, 1] but identify [1, 0] as -> [0, 1, 0]
<RX14->
jmg_, JSON::PullParser is really quite nice, and you would only have to write the code to deal with that one array and use it as a custom deserialiser for the object
<jhass>
ryanw-se: it doesn't
<jmg_>
RX14-: Thanks. In that case, I'll definitely look more into it. Just wanted to double-check that there wasn't an easy way out using union types and JSON.mapping
<RX14->
i don't think so, if you look at the JSON.mapping docs you'll see that you can specify a custom converter for any field on a json object
<RX14->
which looks like it would be what you want
<jhass>
jmg_: you can also use JSON.parse or JSON::Any in a mapping and do casting https://carc.in/#/r/zf9
<jhass>
(and .is_a?)
<RX14->
jhass, where's an example of pull parser usage, it's really quite simple https://carc.in/#/r/zfa
<jmg_>
jhass: Ah, hadn't thought about that- I'll try out both methods
<RX14->
oops
<RX14->
s/jhass/jmg_/
<jmg_>
RX14-: Thanks!
<RX14->
JSON::PullParser should be better documented
<jhass>
patches welcome ;)
<RX14->
but it's the best interface to pull parsers i've ever used
<RX14->
i even ported it to java
<RX14->
because i wanted a pull parser
<RX14->
and the incumbent ones were shite
<RX14->
man, I really love tuple splatting. I can just splat my typed postgres row tuples directly into a method and its all typed
triangles3 has joined #crystal-lang
Raimondii has joined #crystal-lang
<BlaXpirit>
hm it's awesome that macros don't just paste code but have a return value https://carc.in/#/r/zfb how does it work? or maybe I'm mistaken and this is a coincidence?
<asterite>
RX14-: I never really documented JSON::PullParser because I thought it was more low-level and hard to use. I guess I'll soon add more docs to it. It's true that it's very easy to parse a custom JSON with it :-)
Raimondi has quit [Ping timeout: 258 seconds]
triangles2 has quit [Ping timeout: 258 seconds]
<asterite>
BlaXpirit: it's printing the result at runtime, which happens to be the same as an array literal
<asterite>
but the elements are definitely added at runtime
<BlaXpirit>
asterite, I think you misunderstood me. what I mean to say is this: https://carc.in/#/r/zfd does not happen
<jhass>
why is that p _tmpxxx though and not p _tmpxx = [] of Int32; _tmpxxx ....
<asterite>
The %a syntax is only available inside macros
<asterite>
Hmm... we need someone who understands openssl really well, and make him/her a committer... otherwise openssl will be stuck forever
<jhass>
asterite: still not the question
Raimondii is now known as Raimondi
<BlaXpirit>
jhass, I see that you understand me. was that a surprise to you as well?
<asterite>
we can document it, but I always saw a macro like a method that's executed at compile time. So, similar to a method, you don't need to put many expressions inside begin/end
<BlaXpirit>
well something isn't right because as a newcomer I understood it as pasting text as code
<asterite>
Mmm... it's more like, the output of the macro is pasted into the program, but programatically... and so you can paste a series of expressions (Expressions node) like that, but to write it you need begin/end
emancu has joined #crystal-lang
<RX14>
it works on the AST level right
<RX14>
the macro debug() output is desugared as if it's converted back from an AST
<RX14>
asterite, where's the macro docs gone on crystal-lang.org/api/ >
<asterite>
Into Crystal::Macros
<asterite>
I should probably have documented that in the changelog
<leafybasil>
Yeah Im reading that code now. It's clever, but also far less convenient than an inbuilt macro/config
<jhass>
I don't disagree obviously ;)
<leafybasil>
:0
<leafybasil>
:)
<jhass>
feel free to open a new PR tackling that issue (and referencing mine doing so), shows there's some demand for a solution to this ;)
<leafybasil>
Well crystal syntax so far has been really nice (obviously), so it seems uncharacteristic to have to write something like this for what is a fairly common case
<leafybasil>
I shall do thanks
<jhass>
I could also imagine something like Transaction.from_json(json, root: "transaction") for the API