Re: how to send SSL certificate in POST request?
Nice :-) Under the hood it uses (puppetlabs.http.client.common/make-request) . I found the definition of the protocol, but not the actual implementation of make-request . Well, that doesn't matter so much, now I've got something that works! Thank you again -- Pierre Masci On 24 February 2017 at 14:55, Kevin Corcoran <kwcorco...@gmail.com> wrote: > On Thu, Feb 23, 2017 at 5:11 PM, mascip <mas...@gmail.com> wrote: > >> Amazing, thank you James, thank you Micheal, it works! >> >> In Perl things are often pretty complex, but in this specific case the >> code is dead easy: >> >> my $client = REST::Client->new( >> cert => '/path/to/ssl.cert', >> key => '/path/to/ssl.key'); >> >> my $response = $client->POST( >> 'https://.../api/certlogin', >> 'username=' . $username . '=' . $->password); >> >> >> -- Pierre Masci >> > > > Pierre, you might be interested in https://github.com/ > puppetlabs/clj-http-client. It provides an HTTP client which has an > interface like you're describing. The docs appear to be a bit lacking, but > you can basically write: > > (let [client (http/create-client > {:ssl-cert "/path/to/ssl.cert" >:ssl-key "/path/to/ssl.key" >:ssl-ca-cert "/path/to/ssl.cert"})] > (http/post client "https://.../api/certlogin;)) > > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to a topic in the > Google Groups "Clojure" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/clojure/Bh0gl5QEUsI/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: how to send SSL certificate in POST request?
Amazing, thank you James, thank you Micheal, it works! In Perl things are often pretty complex, but in this specific case the code is dead easy: my $client = REST::Client->new( cert => '/path/to/ssl.cert', key => '/path/to/ssl.key'); my $response = $client->POST( 'https://.../api/certlogin', 'username=' . $username . '=' . $->password); -- Pierre Masci On 22 February 2017 at 21:17, Michael Ballwrote: > I had to do the same several months ago. You will need to create a java > key store with the certificate. Once you have a keystore, here's the > clj-http docs on how to include it in an http request. > > https://github.com/dakrone/clj-http#keystores-trust-stores > > (client/post "https://example.com; {:keystore "/path/to/keystore.ks" > :keystore-type "jks" ; default: jks > :keystore-pass "secretpass"}) > > > > > > I don't know if it's much use to you but here's how I created the keystore > using openssl first to convert to pkcs12 then the java keytool to build the > keystore. > > openssl pkcs12 -export -in cert.pem -inkey "private_key.pem" -certfile >> cert.pem -out keystore.p12 >> > > >> keytool -importkeystore -srckeystore keystore.p12 -srcstoretype PKCS12 >> -destkeystore keystore.jks >> > > >> keytool -import -alias ejbca -keystore keystore.jks -file >> VDPCA-Sandbox.pem -storepass password > > > > > > > > > On Tuesday, February 21, 2017 at 3:36:41 PM UTC-8, Pierre Masci wrote: >> >> Hi, I am new to Clojure and using clj-http for the first time, to >> implement a REST client. >> I don't find anywhere how to indicate where my SSL certificate is located. >> Here is what I did: >> >> (ns my-client.core >> (:require [clj-http.client :as client] >> [clojure.pprint :refer :all])) >> >> (def my-appkey "...") >> >> (defn login [username password appkey] >> (client/post "https://.../api/certlogin; >>{:headers {"X-Application" appkey >> "Content-Type" >> "application/x-www-form-urlencoded"} >> :form-params {"username" username "password" password}})) >> >> (defn -main [] >> (pprint (login "..." "..." my-appkey))) >> >> >> This sends me back a response which indicates that I need to send the SSL >> certificate. >> When I send the same request with curl and indicate the certificates, it >> works. This is the successful curl request: >> >> curl -q -k --cert client-2048.crt --key client-2048.key >> https://.../api/certlogin >> -d "username=...=..." -H "X-Application: ..." >> >> >> >> -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to a topic in the > Google Groups "Clojure" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/clojure/Bh0gl5QEUsI/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: A few String functions we could implement in Clojure?
I have voted your issue up, and added a comment. Thanks for the link :-) -- Pierre Masci On 1 August 2014 11:16, Bozhidar Batsov bozhidar.bat...@gmail.com wrote: I recently raised a similar point regarding `starts-with?` and `ends-with?` (link - http://dev.clojure.org/jira/browse/CLJ-1449) and it seems that Clojure's team acknowledges that this is valid reasoning. I think you should open a ticket as well as the case you present is pretty much the same. With ClojureScript and cljx it makes much more sense now to create portable interfaces that it used to before (in the era of Java-only Clojure). On Saturday, July 19, 2014 6:56:44 PM UTC+3, Pierre Masci wrote: Thank you for your insight Andy :-) Interesting question Bruce. -- Pierre Masci On 19 July 2014 16:49, Andy Fingerhut andy.fi...@gmail.com wrote: I would have to defer that question to someone who makes decisions regarding what goes into Clojure/ClojureScript, and what does not. Of course, anyone else is free to create libraries that try to make portability between those two platforms easier. Perhaps someone has already taken a go at creating such a thing? I haven't used ClojureScript myself yet, so haven't looked for anything in that area. Andy On Sat, Jul 19, 2014 at 8:23 AM, Bruce Durling b...@otfrom.com wrote: Andy, How much of this reasoning do you think changes when we starting thinking about being hosted on multiple platforms (I'm thinking specifically clojure/clojurescript and cljx)? cheers, Bruce On Sat, Jul 19, 2014 at 4:17 PM, Andy Fingerhut andy.fi...@gmail.com wrote: Pierre: I maintain the cheatsheet, and I put .indexOf and .lastIndexOf on there since they are probably the most common thing I saw asked about that is in the Java API but not the Clojure API, for strings. There are also links to whole Java classes and their entire API, e.g. for file I/O, for which there is no Clojure equivalent, since file I/O is a common need. Clojure is meant to be a hosted language, not hiding its host platform, but making it easily callable. If there are entire Java classes that meet very common needs that aren't mentioned on the cheatsheet, I would consider adding links to their documentation pages. I don't want to fill up the cheatsheet with many individual Java methods, though. As for why there are not Clojure equivalents of particular Java API methods, I think the reasoning might be similar (it has likely been discussed publicly, but I don't have a link handy) -- don't create a large number of Clojure functions that do nothing more than what the equivalent Java APIs do. Andy On Sat, Jul 19, 2014 at 3:58 AM, Pierre Masci mas...@gmail.com wrote: Hi all, just nit picking about Clojure's String API. I've been comparing it with Java's, and I noticed that (not surprisingly) they are very similar. There are just 2-3 functions that exist in Java but don't have an equivalent in Clojure. I was wondering if they could be worth adding to clojure.string : (.indexOf s c) and (.lastIndexOf c) (.startsWith s danc) and (.endsWith s ing) (.charAt s 5) same as (get s 5) but expresses a clearer intent. It's less general than (get) though as it only applies to Strings, so that might be unnecessary sugar. .indexOf and .lastIndexOf are indicated in the Clojure Cheatsheet, maybe .startsWith and .endsWith also deserve to be mentioned there? I've been wondering why some functions have been ported, like (lower-case) for (.toLowerCase), but not the ones mentioned above. I told you it was nit picking (^c^) Clojure's API is awesome as it is. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and
Re: clojure.stacktrace/root-cause VS clojure.repl/root-cause, are they redundant?
Thank you Stuart, this is a very useful answer. Is there any way to access an exception older than *e? What happens to me regularly is to mistype (.printStackTrace *e), which makes me lost my previous exception. -- Pierre Masci On 24 July 2014 13:33, Stuart Sierra the.stuart.sie...@gmail.com wrote: They're just different versions of the same thing, written at different times by different people, that both got merged into Clojure at different times. Speaking as the original author of clojure.stacktrace, I now think neither one of them should exist. The .printStackTrace method on an exception gives you all the same information and is more reliable. -S On Monday, July 21, 2014 7:30:17 AM UTC-4, Pierre Masci wrote: Hi, I'm learning about tools to help me debug from the REPL, and I found these two with the same name: clojure.stacktrace/root-cause clojure.repl/root-cause -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to a topic in the Google Groups Clojure group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/Ic-49W9ZEac/unsubscribe. To unsubscribe from this group and all its topics, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: clojure.stacktrace/root-cause VS clojure.repl/root-cause, are they redundant?
Saving *e in a def for further investigation, handy :) Cheers On 24 Jul 2014 15:48, Andy Fingerhut andy.finger...@gmail.com wrote: I know of no way that older exceptions than *e are automatically saved anywhere (unlike the results of previous REPL expressions, of which the last 3 are saved in *1 *2 *3). When an exception occurs, it is probably much less error-prone to type a short expression like (def e1 *e) to save the exception in e1, even if another exception occurs after that which modifies *e. Andy On Thu, Jul 24, 2014 at 6:46 AM, mascip mas...@gmail.com wrote: Thank you Stuart, this is a very useful answer. Is there any way to access an exception older than *e? What happens to me regularly is to mistype (.printStackTrace *e), which makes me lost my previous exception. -- Pierre Masci On 24 July 2014 13:33, Stuart Sierra the.stuart.sie...@gmail.com wrote: They're just different versions of the same thing, written at different times by different people, that both got merged into Clojure at different times. Speaking as the original author of clojure.stacktrace, I now think neither one of them should exist. The .printStackTrace method on an exception gives you all the same information and is more reliable. -S On Monday, July 21, 2014 7:30:17 AM UTC-4, Pierre Masci wrote: Hi, I'm learning about tools to help me debug from the REPL, and I found these two with the same name: clojure.stacktrace/root-cause clojure.repl/root-cause -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to a topic in the Google Groups Clojure group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/Ic-49W9ZEac/unsubscribe. To unsubscribe from this group and all its topics, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to a topic in the Google Groups Clojure group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/Ic-49W9ZEac/unsubscribe. To unsubscribe from this group and all its topics, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: A few String functions we could implement in Clojure?
Thank you for your insight Andy :-) Interesting question Bruce. -- Pierre Masci On 19 July 2014 16:49, Andy Fingerhut andy.finger...@gmail.com wrote: I would have to defer that question to someone who makes decisions regarding what goes into Clojure/ClojureScript, and what does not. Of course, anyone else is free to create libraries that try to make portability between those two platforms easier. Perhaps someone has already taken a go at creating such a thing? I haven't used ClojureScript myself yet, so haven't looked for anything in that area. Andy On Sat, Jul 19, 2014 at 8:23 AM, Bruce Durling b...@otfrom.com wrote: Andy, How much of this reasoning do you think changes when we starting thinking about being hosted on multiple platforms (I'm thinking specifically clojure/clojurescript and cljx)? cheers, Bruce On Sat, Jul 19, 2014 at 4:17 PM, Andy Fingerhut andy.finger...@gmail.com wrote: Pierre: I maintain the cheatsheet, and I put .indexOf and .lastIndexOf on there since they are probably the most common thing I saw asked about that is in the Java API but not the Clojure API, for strings. There are also links to whole Java classes and their entire API, e.g. for file I/O, for which there is no Clojure equivalent, since file I/O is a common need. Clojure is meant to be a hosted language, not hiding its host platform, but making it easily callable. If there are entire Java classes that meet very common needs that aren't mentioned on the cheatsheet, I would consider adding links to their documentation pages. I don't want to fill up the cheatsheet with many individual Java methods, though. As for why there are not Clojure equivalents of particular Java API methods, I think the reasoning might be similar (it has likely been discussed publicly, but I don't have a link handy) -- don't create a large number of Clojure functions that do nothing more than what the equivalent Java APIs do. Andy On Sat, Jul 19, 2014 at 3:58 AM, Pierre Masci mas...@gmail.com wrote: Hi all, just nit picking about Clojure's String API. I've been comparing it with Java's, and I noticed that (not surprisingly) they are very similar. There are just 2-3 functions that exist in Java but don't have an equivalent in Clojure. I was wondering if they could be worth adding to clojure.string : (.indexOf s c) and (.lastIndexOf c) (.startsWith s danc) and (.endsWith s ing) (.charAt s 5) same as (get s 5) but expresses a clearer intent. It's less general than (get) though as it only applies to Strings, so that might be unnecessary sugar. .indexOf and .lastIndexOf are indicated in the Clojure Cheatsheet, maybe .startsWith and .endsWith also deserve to be mentioned there? I've been wondering why some functions have been ported, like (lower-case) for (.toLowerCase), but not the ones mentioned above. I told you it was nit picking (^c^) Clojure's API is awesome as it is. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- @otfrom | CTO co-founder @MastodonC | mastodonc.com See recent coverage of us in the Economist http://econ.st/WeTd2i and the Financial Times http://on.ft.com/T154BA -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more