How I can use :8080/admin/export with TLS

Hello.
I used the following commands
gigihont@ubn:~/secure$ dgraph zero --my=192.168.1.97:5080 -w zeroSingle | tee -a Zero_output.txt
[Decoder]: Using assembly version of decoder
I0302 14:08:17.858770 1726 init.go:98]

Dgraph version : v2.0.0-rc1
Dgraph SHA-256 : 447ca408b0e56702568f25ceab89eb712090f5f19f06752b70b9a28ca1260cd6
Commit SHA-1 : a4af81a36
Commit timestamp : 2020-02-14 17:05:06 -0800
Branch : HEAD
Go version : go1.13.7

dgraph alpha --whitelist=192.168.1.117 --tls_client_auth VERIFYIFGIVEN --my=192.168.1.97:7080 --l
ru_mb=3512 --zero=192.168.1.97:5080 --tls_dir tls -p serverS/p -w serverS/w -o 0 | tee -a Server_output.txt

dgraph-ratel -tls_crt ./tls/node.crt -tls_key ./tls/node.key

When I try to type a command in the browser’s search bar, I see this

When I try to do an export using curl, I get an error

gigihont@ubn:~/secure$ curl 'https://192.168.1.97:8080/admin/export?format=json'
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

I’m trying with a certificate

gigihont@ubn:~/secure$ curl https://192.168.1.97:8080/admin/export?format=json --cert ./tls/client.user.crt --key ./tls/client.user.key
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

I see errors in dgraph alpha instatce

I0302 18:59:03.857561    2731 groups.go:864] Got Zero leader: 192.168.1.97:5080
I0302 18:59:05.803604    2731 admin.go:391] No GraphQL schema in Dgraph; serving empty GraphQL API
2020/03/02 19:01:04 http: TLS handshake error from 192.168.1.97:42074: remote error: tls: unknown certificate authority
2020/03/02 19:03:41 http: TLS handshake error from 192.168.1.97:42076: remote error: tls: unknown certificate authority
2020/03/02 19:17:33 http: TLS handshake error from 192.168.1.97:42080: remote error: tls: unknown certificate authority

Tell me what I’m doing wrong.

Hello.
I tried making this command but didn’t get the export

gigihont@ubn:~/secure$ curl https://192.168.1.97:8080/admin/export?format=json --cert ./tls/client.user.crt --key ./tls/client.user.key --cacert ./tls/ca.crt
Dgraph browser is available for running separately using the dgraph-ratel binarygigihont@ubn:~/secure$

Have you tried the insecure flag?

It doesn’t work

gigihont@ubn:~/secure$ curl 'https://192.168.1.97:8080/admin/export?format=json' --insecure --cert ./tls/client.user.crt --key ./tls/client.user.key --cacert ./tls/ca.crt
Dgraph browser is available for running separately using the dgraph-ratel binarygigihont@ubn:~/secure$
gigihont@ubn:~/secure$ curl '192.168.1.97:8080/admin/export?format=json' --insecure --cert ./tls/client.user.crt --key ./tls/client.user.key --cacert ./tls/ca.crt
Client sent an HTTP request to an HTTPS server.

Hello.
Is this problem with curl?

gigihont@ubn:~$ curl -V
curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.1 zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Release-Date: 2018-01-24
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL

Not sure, I’ll check this.

Until there, try with wget HTTPS (SSL/TLS) Options (GNU Wget 1.21.1-dirty Manual)

Cheers.

Hello.
I can 't export anything at all
Where is my mistake
On windows 10
dgraph zero
dgraph alpha --lru_mb 4096
curl http://localhost:8080/admin/export

StatusCode        : 200
StatusDescription : OK
Content           : Dgraph browser is available for running separately using the dgraph-ratel binary
RawContent        : HTTP/1.1 200 OK
                    Content-Length: 80
                    Content-Type: text/plain; charset=utf-8
                    Date: Wed, 04 Mar 2020 11:06:47 GMT

                    Dgraph browser is available for running separately using the dgraph-ratel binary
Forms             : {}
Headers           : {[Content-Length, 80], [Content-Type, text/plain; charset=utf-8], [Date, Wed, 04 Mar 2020 11:06:47
                    GMT]}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 80

Maybe this is the issue. I think in that version this export endpoint was removed (It will be deprecated, but in the future, in the latest version it is back). You need to use the GraphQL Admin endpoint tho.

Use cURL or some GraphQL UI (e.g. Insomnia REST Client) and run this mutation.

mutation {
		export(input: {format: "rdf"}) {
			response {
				code
				message
			}
		}
	}

It doesn’t work.
Maybe I’m doing something wrong

the endpoint is :8080/admin

Ok. How I can fix ErrorUnauthorized

You have to whitelist your IP or the host IP if you are using a VM.

Ok. I fix it with code:

dgraph alpha --lru_mb 2048 --whitelist 192.168.0.111

I added some data
I got the error again

How I can fix ‘unable to parse media type’?

must be something else
try with curl e.g dgraph/test-bulk-schema.sh at fa17103ee02397acae317af5bd447d486d4c455d · dgraph-io/dgraph · GitHub

I tried this code:

curl -Ss -H "Content-Type: application/json" http://192.168.0.199:8000/admin -XPO
ST -d '{ "query": "mutation { export(input: {format: \"rdf\"}) { response { code message } }}" }'

But again I got an error:
Asset not found for path admin

It is 8080 not 8000 (8000 is Ratel’s port)

BTW, read the changelog from Dgraph v2.0.0-rc1.

Removed

  • Remove HTTP admin endpoints. The same functionality is available via GraphQL Admin API. Please see below. (#4754)
1 Like

It works for dgraph version : v2.0.0-rc1
My ip addr is 192.168.0.111
Target computer ip is 192.168.0.199

dgraph zero
dgraph alpha --lru_mb 2048 --whitelist localhost,192.168.0.111

You can do curl from 192.168.0.111 or localhost (http://localhost:8080/admin)

curl -Ss -H “Content-Type: application/json” http://192.168.0.199:8080/admin -XPOST -d ‘{ “query”: “mutation { export(input: {format: “rdf”}) { response { code message } }}” }’

It’s response:
{“data”:{“export”:{“response”:{“code”:“Success”,“message”:“Export completed.”}}}}