Merge pull request #11 from liquidz/bugfix

#10 bugfix: public-key-from-string on invalid key string
This commit is contained in:
Masashi Iizuka 2015-02-26 07:46:07 +09:00
commit eb9a202a1d
4 changed files with 7 additions and 5 deletions

View file

@ -86,6 +86,6 @@ A Clojure library for JSON Web Token(JWT) [draft-ietf-oauth-json-web-token-19](h
## License
Copyright © 2014 [uochan](http://twitter.com/uochan)
Copyright © 2015 [uochan](http://twitter.com/uochan)
Distributed under the Eclipse Public License, the same as Clojure.

View file

@ -1,4 +1,4 @@
(defproject clj-jwt "0.0.11"
(defproject clj-jwt "0.0.12"
:description "Clojure library for JSON Web Token(JWT)"
:url "https://github.com/liquidz/clj-jwt"
:license {:name "Eclipse Public License"
@ -8,7 +8,7 @@
[org.clojure/data.codec "0.1.0"]
[org.bouncycastle/bcprov-jdk15 "1.46"]
[crypto-equality "1.0.0"]
[clj-time "0.8.0"]]
[clj-time "0.9.0"]]
:profiles {:dev {:dependencies [[midje "1.6.3" :exclusions [org.clojure/clojure]]]}}
:plugins [[lein-midje "3.1.3"]])

View file

@ -38,7 +38,7 @@
(defn public-key-from-string
[key-str & [pass-phrase]]
(with-open [r (StringReader. key-str)]
(let [res (pem->key r pass-phrase)]
(when-let [res (pem->key r pass-phrase)]
(if (public-key? res)
res
(.getPublic res)))))

View file

@ -45,7 +45,9 @@
(fact "rsa encrypted key with wrong pass phrase from string"
(-> "test/files/rsa/3des.key" slurp (public-key-from-string "wrong pass phrase") type)
=> (throws org.bouncycastle.openssl.EncryptionException))
)
(fact "invalid key string"
(public-key-from-string "foobar") => nil))
(facts "ecdsa public key"
(fact "ecdsa public key"