#10 bugfix: public-key-from-string on invalid key string
This commit is contained in:
parent
b2ee035c64
commit
d65835283b
4 changed files with 7 additions and 5 deletions
|
@ -86,6 +86,6 @@ A Clojure library for JSON Web Token(JWT) [draft-ietf-oauth-json-web-token-19](h
|
||||||
|
|
||||||
## License
|
## 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.
|
Distributed under the Eclipse Public License, the same as Clojure.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(defproject clj-jwt "0.0.11"
|
(defproject clj-jwt "0.0.12"
|
||||||
:description "Clojure library for JSON Web Token(JWT)"
|
:description "Clojure library for JSON Web Token(JWT)"
|
||||||
:url "https://github.com/liquidz/clj-jwt"
|
:url "https://github.com/liquidz/clj-jwt"
|
||||||
:license {:name "Eclipse Public License"
|
:license {:name "Eclipse Public License"
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
[org.clojure/data.codec "0.1.0"]
|
[org.clojure/data.codec "0.1.0"]
|
||||||
[org.bouncycastle/bcprov-jdk15 "1.46"]
|
[org.bouncycastle/bcprov-jdk15 "1.46"]
|
||||||
[crypto-equality "1.0.0"]
|
[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]]]}}
|
:profiles {:dev {:dependencies [[midje "1.6.3" :exclusions [org.clojure/clojure]]]}}
|
||||||
:plugins [[lein-midje "3.1.3"]])
|
:plugins [[lein-midje "3.1.3"]])
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
(defn public-key-from-string
|
(defn public-key-from-string
|
||||||
[key-str & [pass-phrase]]
|
[key-str & [pass-phrase]]
|
||||||
(with-open [r (StringReader. key-str)]
|
(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)
|
(if (public-key? res)
|
||||||
res
|
res
|
||||||
(.getPublic res)))))
|
(.getPublic res)))))
|
||||||
|
|
|
@ -45,7 +45,9 @@
|
||||||
(fact "rsa encrypted key with wrong pass phrase from string"
|
(fact "rsa encrypted key with wrong pass phrase from string"
|
||||||
(-> "test/files/rsa/3des.key" slurp (public-key-from-string "wrong pass phrase") type)
|
(-> "test/files/rsa/3des.key" slurp (public-key-from-string "wrong pass phrase") type)
|
||||||
=> (throws org.bouncycastle.openssl.EncryptionException))
|
=> (throws org.bouncycastle.openssl.EncryptionException))
|
||||||
)
|
|
||||||
|
(fact "invalid key string"
|
||||||
|
(public-key-from-string "foobar") => nil))
|
||||||
|
|
||||||
(facts "ecdsa public key"
|
(facts "ecdsa public key"
|
||||||
(fact "ecdsa public key"
|
(fact "ecdsa public key"
|
||||||
|
|
Loading…
Reference in a new issue