Jonathan Turner 9 лет назад
Родитель
Сommit
4020cb33bc
3 измененных файлов с 4 добавлено и 4 удалено
  1. 1 1
      README.md
  2. 2 2
      client/http.go
  3. 1 1
      debug.go

+ 1 - 1
README.md

@@ -67,7 +67,7 @@ tkt, err := cl.GetServiceTicket("HTTP/host.test.gokrb5")
 Create the HTTP request object and then call the client's SetSPNEGOHeader method passing the Service Principal Name (SPN)
 ```go
 r, _ := http.NewRequest("GET", "http://host.test.gokrb5/index.html", nil)
-cl.SetSPNEGOHeader(r, "HTTP/host.test.gokrb5")
+cl.SetSPNEGOHeader(r)
 HTTPResp, err := http.DefaultClient.Do(r)
 ```
 

+ 2 - 2
client/http.go

@@ -7,8 +7,8 @@ import (
 	"net/http"
 )
 
-func (cl *Client) SetSPNEGOHeader(HTTPReq *http.Request, spn string) error {
-	tkt, skey, err := cl.GetServiceTicket(spn)
+func (cl *Client) SetSPNEGOHeader(HTTPReq *http.Request) error {
+	tkt, skey, err := cl.GetServiceTicket("HTTP/" + HTTPReq.Host)
 	if err != nil {
 		return fmt.Errorf("Could not get service ticket: %v", err)
 	}

+ 1 - 1
debug.go

@@ -73,7 +73,7 @@ func httpRequest() {
 		fmt.Fprintf(os.Stderr, "Error on AS_REQ: %v\n", err)
 	}
 	r, _ := http.NewRequest("GET", "http://host.test.gokrb5/index.html", nil)
-	cl.SetSPNEGOHeader(r, "HTTP/host.test.gokrb5")
+	cl.SetSPNEGOHeader(r)
 	httpResp, err := http.DefaultClient.Do(r)
 	fmt.Fprintf(os.Stderr, "RESPONSE CODE: %v\n", httpResp.StatusCode)
 }