2011-01-28 07:07:18 +00:00
|
|
|
/*
|
|
|
|
Copyright 2011 Google Inc.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2010-11-30 07:22:11 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
2010-12-03 15:34:24 +00:00
|
|
|
$ gpg --no-default-keyring --keyring=/tmp/foo --import --armor test/pubkey-blobs/sha1-82e6f3494f69
|
2010-11-30 07:22:11 +00:00
|
|
|
|
2010-12-03 15:34:24 +00:00
|
|
|
$ gpg --no-default-keyring --keyring=/tmp/foo --verify sig.tmp doc.tmp ; echo $?
|
|
|
|
gpg: Signature made Mon 29 Nov 2010 10:59:52 PM PST using RSA key ID 26F5ABDA
|
|
|
|
gpg: Good signature from "Camli Tester <camli-test@example.com>"
|
|
|
|
gpg: WARNING: This key is not certified with a trusted signature!
|
|
|
|
gpg: There is no indication that the signature belongs to the owner.
|
|
|
|
Primary key fingerprint: FBB8 9AA3 20A2 806F E497 C049 2931 A67C 26F5 ABDA0
|
2010-11-30 07:22:11 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
import (
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
"camlistore.org/pkg/httputil"
|
|
|
|
"camlistore.org/pkg/jsonsign"
|
2012-03-26 21:00:07 +00:00
|
|
|
"net/http"
|
2011-07-02 16:09:50 +00:00
|
|
|
)
|
2010-12-03 15:34:24 +00:00
|
|
|
|
2010-12-04 18:12:41 +00:00
|
|
|
func handleVerify(conn http.ResponseWriter, req *http.Request) {
|
|
|
|
if !(req.Method == "POST" && req.URL.Path == "/camli/sig/verify") {
|
2010-12-06 06:34:46 +00:00
|
|
|
httputil.BadRequestError(conn, "Inconfigured handler.")
|
2010-12-04 03:30:08 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2010-12-04 18:12:41 +00:00
|
|
|
req.ParseForm()
|
|
|
|
sjson := req.FormValue("sjson")
|
|
|
|
if sjson == "" {
|
2010-12-06 06:34:46 +00:00
|
|
|
httputil.BadRequestError(conn, "Missing sjson parameter.")
|
2010-12-04 18:12:41 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2010-12-04 21:49:34 +00:00
|
|
|
m := make(map[string]interface{})
|
|
|
|
|
2010-12-14 02:20:31 +00:00
|
|
|
vreq := jsonsign.NewVerificationRequest(sjson, pubKeyFetcher)
|
2010-12-04 21:49:34 +00:00
|
|
|
if vreq.Verify() {
|
|
|
|
m["signatureValid"] = 1
|
|
|
|
m["verifiedData"] = vreq.PayloadMap
|
|
|
|
} else {
|
|
|
|
m["signatureValid"] = 0
|
2012-03-26 21:00:07 +00:00
|
|
|
m["errorMessage"] = vreq.Err.Error()
|
2010-12-04 03:30:08 +00:00
|
|
|
}
|
|
|
|
|
2011-07-02 16:09:50 +00:00
|
|
|
conn.WriteHeader(http.StatusOK) // no HTTP response code fun, error info in JSON
|
2012-07-28 22:42:56 +00:00
|
|
|
httputil.ReturnJSON(conn, m)
|
2010-11-30 07:22:11 +00:00
|
|
|
}
|