Mastodon Network Error inside docker container: app01.fr.maas.network


#1

I have my project built in docker. When I use mastodon api inside my docker container then I am getting following error.
Error:“MastodonNetworkError: Could not complete request: hostname ‘mastodon.social’ doesn’t match ‘app01.fr1.maas.network’”
Can anybody knows why this error is coming and how to solve this error?
I mention my code below
Code:

from mastodon import Mastodon
Mastodon.create_app(
     'ooterapp',
     api_base_url = 'https://mastodon.social',
     to_file = 'client.secret'
)

mastodon = Mastodon(
    client_id = 'client.secret',
    api_base_url = 'https://mastodon.social'
)
mastodon.log_in(
    'abcd@gmail.com',
    'abc@123',
    to_file = 'user.secret'
)

mastodon = Mastodon(
    client_id = 'client.secret',
    access_token = 'user.secret',
    api_base_url = 'https://mastodon.social'
)
mastodon.toot('Tooting from python using #mastodonpy !')

If I use above code outside the docker in another simple python project which resides outside the docker then above code works fine but as soon as I run this code inside the docker in my project I am getting error.


Mastodon Instance OS Requirement
#2

Can you check if your Internet provider isn’t hijacking the HTTPS session?

What does this say?

openssl s_client -showcerts -connect mastodon.social:443

#3

The command is running inside docker container and it gives me the key and all other information.


#4

I am getting following output for that command:::

depth=1 C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/CN=app01.fr1.maas.network
   i:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
-----BEGIN CERTIFICATE-----
VNnYVgk4nOAA9Tx9XPsZXN2+SU8jt4R190tXcg5PoY/9qfbuWH6Gw7//xD9OrHwl
WIPquV3gxgCh/HnfjRaAd4dDbsIRwohbI0Jq1P4PRGB9qCnY+nfUeTJ8FLdEQ1ee
9xUvUOsY1PIHB5L0qEYhB08Ej5/1cozVDiNG0bj25RJxMD6gqrzHXV8Mxzk8LShS
LfevEv6zOGlUmVSBsrOZ1ggLgl9CXHQ+0BjwPG0oDZoVpHhMNb/K7zdSuDSzd528
BIgPZRcJuJZSKUuqe8Uw/reB69S87F9UAJeU9CPZ7yVWyj+G4BfLWm+t+V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yZXBvc2l0b3J5LzANBgkqhkiG9w0BAQsFAAOC
AQEAmr3Br+/9wSJuqRDICaccYfmZW6FO9E0DJFTxl+22qBGwfxRma56cwZJr9D3A
wOW3Y3e1Hyw1uZQrDe78vrmINV2NZUcufMKKxt6GYuysksoWMQZsvp7xk5B/7ZEE
TW8E7XYnsMuc0cjTNKY91wetpRssfzmgfCdYGaGgDHzkyt9ofB5SsLK7Bu6p285j
mf5DtpejjBfmSJGvqYvrDCdRnEBH6ujSDntBM1EfXXOcAyceUY7gbJ67KmhzZ1zW
EH6e4d9YTuKV8GVhl63z6PFNg8kuRNKslF5r4CLNsJDk4+ZDR0JNytyL5cpdgjQk
ZyFMnETxUI7hromA02rcklVKeA==
-----END CERTIFICATE-----
 1 s:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
   i:/O=Digital Signature Trust Co./CN=DST Root CA X3
-----BEGIN CERTIFICATE-----
q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8
SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0
Z8h/pZq4UmEUEz9l6YKHy9v6Dlb2honzhT+Xhq+w3Brvaw2VFn3EK6BlspkENnWA
a6xK8xuQSXgvopZPKiAlKQTGdMDQMc2PMTiVFrqoM7hD8bEfwzB/onkxEz0tNvjj
/PIzark5McWvxI0NHWQWM6r6hCm21AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0T
AQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIG
CCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9jc3AuaWRlbnRydXN0LmNv
bTA7BggrBgEFBQcwAoYvaHR0cDovL2FwcHMuaWRlbnRydXN0LmNvbS9yb290cy9k
c3Ryb290Y2F4My5wN2MwHwYDVR0jBBgwFoAUxKexpHsscfrb4UuQdf/EFWCFiRAw
VAYDVR0gBE0wSzAIBgZngQwBAgEwPwYLKwYBBAGC3xMBAQEwMDAuBggrBgEFBQcC
ARYiaHR0cDovL2Nwcy5yb290LXgxLmxldHNlbmNyeXB0Lm9yZzA8BgNVHR8ENTAz
MDGgL6AthitodHRwOi8vY3JsLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwu
Y3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsF
AAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJo
uM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/
wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu
X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG
PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6
KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==
-----END CERTIFICATE-----
---
Server certificate
subject=/CN=app01.fr1.maas.network
issuer=/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
---
No client certificate CA names sent
---
SSL handshake has read 3527 bytes and written 453 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256
Server public key is 4096 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES256
    Session-ID: A60EACE814355374A08B1A493C98926B5C2EECD404A60900BB8E8
    Session-ID-ctx: 
    Master-Key: 9511EAE4BF8872AE05EFB
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1518674757
    Timeout   : 300 (sec)
    Verify return code: 20 (unable to get local issuer certificate)


#5

As suspected, you are not connecting to mastodon.social but to app01.fr.maas.network

Maybe there is some misconfiguration on your side or your network is taking over HTTP requests.


#6

Is mastodon only support ubuntu 16.04 and above? Because when I try to run below code in ubuntu:14.04 then I got "Error:“MastodonNetworkError: Could not complete request: hostname ‘mastodon.social’ doesn’t match ‘app01.fr1.maas.network” but when I run same code in ubuntu:16.04 then it doesn’t give me any error and works fine. Is mastodon has anything to do with my OS version??

Code:::

from mastodon import Mastodon
Mastodon.create_app(
     'ooterapp',
     api_base_url = 'https://mastodon.social',
     to_file = 'client.secret'
)

mastodon = Mastodon(
    client_id = 'client.secret',
    api_base_url = 'https://mastodon.social'
)
mastodon.log_in(
    'abc@gmail.com',
    'abc',
    to_file = 'user.secret'
)

mastodon = Mastodon(
    client_id = 'client.secret',
    access_token = 'user.secret',
    api_base_url = 'https://mastodon.social'
)
mastodon.toot('Tooting from python using #mastodonpy !')

#7

Haven’t tried, but this is the same problem as you have reported above. Do not think it is related to your Ubuntu version. There is something strange in your network configuration. Do you have IPv6 enabled? What does your /sbin/ip addr list say?

I am afraid you have to talk to your network administrator.


#8

Hey Saper…we don’t use ipv6 here.We use ipv4 only. Actually I am not understanding that same code is working in docker container ubuntu 16.04 but it is not working in docker container of ubuntu 14.04 . When I use “”/sbin/ip addr list"" command in my local system then I got following output.
output::

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether ec:f4:bb:79:de:69 brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 44:1c:a8:0e:a8:01 brd ff:ff:ff:ff:ff:ff
    inet 10.3.1.80/22 brd 10.3.3.255 scope global dynamic wlp2s0
       valid_lft 86029sec preferred_lft 86029sec
    inet6 fe80::8fb8:15df:11f7:a3c/64 scope link 
       valid_lft forever preferred_lft forever
4: br-a9cbe9dfa020: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:29:7a:3a:ab brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global br-a9cbe9dfa020
       valid_lft forever preferred_lft forever
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:f3:b9:5b:18 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever

##############################################################
->When I use “/sbin/ip addr list” command in my docker container of ubuntu 14.04 then I got following output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
6: eth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever

->When I use “/sbin/ip addr list” command in my docker container of ubuntu 16.04 then I got following output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
8: eth0@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:11:00:03 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.17.0.3/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever

#9

Where os your wlp2s0 interface connected to? Is your default route pointing towards wireless interface?


#10

My ifconfig gives me following output::::::::;

br-a9cbe9dfa020 Link encap:Ethernet HWaddr 02:42:70:04:dc:c1
inet addr:172.18.0.1 Bcast:172.18.255.255 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

docker0 Link encap:Ethernet HWaddr 02:42:cf:a9:db:47
inet addr:172.17.0.1 Bcast:172.17.255.255 Mask:255.255.0.0
inet6 addr: fe80::42:cfff:fea9:db47/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:164656 errors:0 dropped:0 overruns:0 frame:0
TX packets:257345 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:10478039 (10.4 MB) TX bytes:390049892 (390.0 MB)

enp1s0 Link encap:Ethernet HWaddr ec:f4:bb:79:de:69
inet addr:10.3.1.145 Bcast:10.3.3.255 Mask:255.255.252.0
inet6 addr: fe80::deb7:7399:5be7:8ba9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:489573 errors:0 dropped:0 overruns:0 frame:0
TX packets:181938 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:450147359 (450.1 MB) TX bytes:15827413 (15.8 MB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:4303 errors:0 dropped:0 overruns:0 frame:0
TX packets:4303 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:599478 (599.4 KB) TX bytes:599478 (599.4 KB)

veth4aecc05 Link encap:Ethernet HWaddr ee:08:97:74:e1:e7
inet6 addr: fe80::ec08:97ff:fe74:e1e7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:31397 errors:0 dropped:0 overruns:0 frame:0
TX packets:50706 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2395112 (2.3 MB) TX bytes:77135427 (77.1 MB)

wlp2s0 Link encap:Ethernet HWaddr 44:1c:a8:0e:a8:01
inet addr:10.3.1.80 Bcast:10.3.3.255 Mask:255.255.252.0
inet6 addr: fe80::8fb8:15df:11f7:a3c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:266033 errors:0 dropped:1 overruns:0 frame:0
TX packets:5252 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:63999243 (63.9 MB) TX bytes:585171 (585.1 KB)


#11

This issue is solved after installing “ndg-httpsclient” package in my docker container of ubuntu4 where earlier it was not working but now it is working. I used following command
apt-get install ndg-httpsclient