0

我正在尝试运行 curl put 请求,但我得到一个未经处理的响应,我担心这是基于我的服务器设置。

请求如下:

curl  -X PUT -v -u 'admin:adminpwd' https://myexampledomain.com/cloud/ocs/v1.php/cloud/users/pinuccio -d 'key=display' -d 'value=ajeje' -H "OCS-APIRequest: true"

我得到的响应是 unhautorized (401)。这是详细日志:

*   Trying 127.0.1.1...
* TCP_NODELAY set
* Connected to myexampledomain.com (127.0.1.1) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Unknown (8):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Client hello (1):
* TLSv1.3 (OUT), TLS Unknown, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: CN=myexampledomain.com
*  start date: May  1 17:18:35 2020 GMT
*  expire date: Jul 30 17:18:35 2020 GMT
*  subjectAltName: host "myexampledomain.com" matched cert's "myexampledomain.com"
*  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
*  SSL certificate verify ok.
* Server auth using Basic with user 'admin'
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
> PUT /cloud/ocs/v1.php/cloud/users/pinuccio HTTP/1.1
> Host: mydomain.com
> Authorization: Basic YWRtaW46QzRsMW0zcjA=
> User-Agent: curl/7.58.0
> Accept: */*
> OCS-APIRequest: true
> Content-Length: 23
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 23 out of 23 bytes
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
< HTTP/1.1 401 Unauthorized
< Date: Tue, 30 Jun 2020 14:07:28 GMT
< Server: Apache/2.4.29 (Ubuntu)
< Strict-Transport-Security: max-age=15552000; includeSubDomains
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< X-Robots-Tag: none
< X-Frame-Options: SAMEORIGIN
< X-Download-Options: noopen
< X-Permitted-Cross-Domain-Policies: none
< Set-Cookie: oczw6f5q1725=a8va678tu6ifnku9qqb8ad6g9r; path=/cloud; secure; HttpOnly
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< Set-Cookie: oc_sessionPassphrase=aX2nBbeRkkjX2AOsL9pWoxCcB5vvtdiR4wT9UtOAxfM61oVxCX5LvX02eZkNSfqUPekCdo20A65%2BplZBgHQo%2FyaVQdiQ42d7O4TAqyWpsx8f3gBAeNV%2B2EphYBGNxLmW; path=/cloud; secure; HttpOnly
< Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src *; img-src * data: blob:; font-src 'self' data:; media-src *; connect-src *
< Set-Cookie: oczw6f5q1725=0h8mkv831pq6aukvoivr7gf5t2; path=/cloud; secure; HttpOnly
< Set-Cookie: cookie_test=test; expires=Tue, 30-Jun-2020 15:07:28 GMT; Max-Age=3600
< Set-Cookie: oc_username=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/cloud; secure; HttpOnly
< Set-Cookie: oc_token=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/cloud; secure; HttpOnly
< Set-Cookie: oc_remember_login=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/cloud; secure; HttpOnly
< Set-Cookie: oc_username=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/cloud/; secure; HttpOnly
< Set-Cookie: oc_token=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/cloud/; secure; HttpOnly
< Set-Cookie: oc_remember_login=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/cloud/; secure; HttpOnly
< Set-Cookie: oczw6f5q1725=pi2oc8f3cgut57emv2ikflsooq; path=/cloud; secure; HttpOnly
< Set-Cookie: oczw6f5q1725=4hhk94mvb1l6j6re7qi9v68kjo; path=/cloud; secure; HttpOnly
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="Authorisation Required"
< Access-Control-Allow-Origin: https://myexampledomain.com/cloud
< Content-Length: 132
< Content-Type: text/xml; charset=UTF-8
< 
* TLSv1.3 (IN), TLS Unknown, Unknown (23):

我无法从日志中了解它失败的地方。谁能帮我理解?我直接从运行 api 的服务器运行请求。我还为 mydomain.com/cloud 添加了 CORS 允许,但没有任何改变。

在同一个 API 上,我可以在没有基本身份验证的情况下运行 POST 请求。该请求运行顺利。看起来在某些时候 TLS1.3 无法继续进行身份验证......

这是 API 文档:用户配置 API - 编辑用户

4

1 回答 1

0

Owncloud 10 API 需要启用 TLS1.3。我正在运行不支持 TLS1.3 的 Apache 2.4.29(这是在 Ubuntu 18.04 服务器上编写时的最新版本)第一个支持它的版本是 2.4.37

我更新了 Apache,现在一切正常。要强制升级,我必须:

//add the repository
sudo add-apt-repository ppa:ondrej/apache2
//get the updates
sudo apt update
//do the upgrade
sudo apt upgrade

希望这可以解决其他人的头痛

于 2020-06-30T17:31:31.183 回答