How to remove the "Could not connect to the iTunes store" error message when your network does not allow access to the iTunes Store
Since the last update, iTunes is unusable for me on my iMac, because with every song change it shows a "Could not connect to the iTunes Store" error message. My network at work does not allow access to the iTunes store, but that is ok. I just want to listen to my local music connection there. I have disabled the iTunes Store in the parental settings completely, but still, the error pops up with each and every song change. Any idea how to prevent iTunes from showing this popup?
There are two major annoyances here in iTunes imho a) iTunes tries to access the store even if it is disabled completely in the settings and you're signed out b) The error messages "staple" on top of each other, so iTunes diplays the same error 1000 times and you have to click them all away. This reminds me of Windows 95 times.
I traced the problem down to a TLS handshake (thanks to jonnydigitol below for the idea!) and a total of 63 packets between the host and 23.211.148.217, which is init.iTunes.apple.com - that is executed when iTunes is started. Once this handshake completes, all is fine and you can use iTunes. But you must tunnel traffic to this host on startup, otherwise you get the error with each and every song change as iTunes tries and tries to connect to init.iTunes and throws an error popup.
Consider the answer below by jonnydigitol - you can connect by mobile phone internet or a tunnel to init.iTunes.apple.com, start iTunes and never ever turn it off - then it keeps working without an internet connection "infinitely".
How to really 'fix' the issue by installing your own web server on localhost that answers the ping:
(Check that your iTunes is up to date, there might be a fix out already)
Open Applications->Utilities->Terminal and enter the following lines
If you do not have homebrew installed, first do this :
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Make sure openssl and node.js are installed
brew install openssl node wget
To redirect init.apple.itunes.com to local
echo '127.0.0.1 init.iTunes.apple.com' | sudo tee -a /etc/hosts
You will need to give your password. Next, create and register your own root certificate.
openssl genrsa -out rootCA.key 2048
openssl genrsa -des3 -out rootCA.key 2048
Enter any pass phrase you like
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
Enter your pass phrase. Leave all lines empty except
Common Name (e.g. server FQDN or YOUR name) []:init.itunes.apple.com
And the same thing once more (same passphrase, same common name)
sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" rootCA.pem
openssl genrsa -out device.key 2048
openssl req -new -key device.key -out device.csr
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 500 -sha256
sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" device.crt
Note response and start your own https server that takes the ping
wget -O response.xml "https://itunes.apple.com/WebObjects/MZStore.woa/wa/initiateSession?ix=1"
echo "var t=require('tls');var f=require('fs');var xmlresp = f.readFileSync('response.xml');var options = {key:f.readFileSync('device.key'),cert:f.readFileSync('device.crt')};var server=t.createServer(options, function (request,response) {request.on('data', function (chunk) {request.write(xmlresp);});});server.listen(443, function() {});" > ims.js
sudo node ims.js
Leave terminal open or minimize it, open Safari
Go to https://init.itunes.apple.com
If you get a trust certificate warning, change the policy to "always trust". If the page loads infintely, everything is fine.
Open iTunes. The error should be gone.
For the future, if you want to use iTunes, open a Terminal and run
sudo node ims.js
Then start iTunes.
Alternatively, revert to an older version.
I had given up on the issue, submitted a bug report to Apple, and, after hearing nothing from them, rolled back to the previous iTunes and rebuild by complete library in an hour long effort. Everything works now again, but I'm really disappointed by Apple here. I'm not (yet) used to them releasing such bad code.
The only way out for me was to use Pacifist to unpack an older iTunes pkg which I downloaded from Apple and extract the App, and then rebuild the complete iTunes library (which is HUGE). This is a kind of hacking I got used to being necessary on Windows systems sometimes, but i cannot remember I had to do such a thing on OSX ever. Until now. What's next, disassemble?
Apple, you have a software quality problem. Just my 2 cents.
News - Apple has processed my bug report and assigned it status "duplicate of 29741441 (OPEN)".
Similar issue since the update. Seems to happen only while listening to iTunes offline. Alas, I may have found a solution (for me at least). Connect your computer to your phone's personal WiFi (I chose USB connect), play a song and voila! No more error! Afterward, I turned off the hotspot (optional) and to my surprise— still no error. Hope this works!