Allow iOS to connect to servers without SSL (#7881) (#7885)

This commit is contained in:
Mattermost Build 2024-03-28 14:37:32 +02:00 committed by GitHub
parent 26896eb61b
commit 2b1dfff8d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 34 additions and 33 deletions

View file

@ -4,16 +4,6 @@ description: Action to prepare environment for ios build
runs:
using: composite
steps:
- name: ci/install-os-deps
env:
HOMEBREW_NO_AUTO_UPDATE: "1"
shell: bash
run: |
echo "::group::install-os-deps"
brew install --overwrite python@3.12
brew install watchman
echo "::endgroup::"
- name: ci/prepare-mobile-build
uses: ./.github/actions/prepare-mobile-build

View file

@ -290,31 +290,34 @@ const Server = ({
cancelPing = undefined;
};
const serverUrl = await getServerUrlAfterRedirect(pingUrl, !retryWithHttp);
if (!serverUrl) {
const ping = await getServerUrlAfterRedirect(pingUrl, !retryWithHttp);
if (!ping.url) {
cancelPing();
if (retryWithHttp) {
const nurl = pingUrl.replace('https:', 'http:');
pingServer(nurl, false);
} else {
setUrlError(getErrorMessage(ping.error, intl));
setButtonDisabled(true);
setConnecting(false);
}
return;
}
const result = await doPing(serverUrl, true, managedConfig?.timeout ? parseInt(managedConfig?.timeout, 10) : undefined);
const result = await doPing(ping.url, true, managedConfig?.timeout ? parseInt(managedConfig?.timeout, 10) : undefined);
if (canceled) {
return;
}
if (result.error) {
if (retryWithHttp) {
const nurl = serverUrl.replace('https:', 'http:');
pingServer(nurl, false);
} else {
setUrlError(getErrorMessage(result.error, intl));
setButtonDisabled(true);
setConnecting(false);
}
setUrlError(getErrorMessage(result.error, intl));
setButtonDisabled(true);
setConnecting(false);
return;
}
canReceiveNotifications(serverUrl, result.canReceiveNotifications as string, intl);
const data = await fetchConfigAndLicense(serverUrl, true);
canReceiveNotifications(ping.url, result.canReceiveNotifications as string, intl);
const data = await fetchConfigAndLicense(ping.url, true);
if (data.error) {
setButtonDisabled(true);
setUrlError(getErrorMessage(data.error, intl));
@ -332,7 +335,7 @@ const Server = ({
}
const server = await getServerByIdentifier(data.config.DiagnosticId);
const credentials = await getServerCredentials(serverUrl);
const credentials = await getServerCredentials(ping.url);
setConnecting(false);
if (server && server.lastActiveAt > 0 && credentials?.token) {
@ -344,7 +347,7 @@ const Server = ({
return;
}
displayLogin(serverUrl, data.config!, data.license!);
displayLogin(ping.url, data.config!, data.license!);
};
const transform = useAnimatedStyle(() => {

View file

@ -7,6 +7,7 @@ import urlParse from 'url-parse';
import {Files} from '@constants';
import {emptyFunction} from '@utils/general';
import {logDebug} from '@utils/log';
import {latinise} from './latinise';
@ -25,8 +26,10 @@ export function sanitizeUrl(url: string, useHttp = false) {
preUrl = urlParse('https://' + stripTrailingSlashes(url), true);
}
if (!protocol || (preUrl.protocol === 'http:' && !useHttp)) {
if (preUrl.protocol === 'http:' && !useHttp) {
protocol = 'https:';
} else if (!protocol) {
protocol = useHttp ? 'http:' : 'https:';
}
return stripTrailingSlashes(
@ -43,12 +46,11 @@ export async function getServerUrlAfterRedirect(serverUrl: string, useHttp = fal
url = resp.redirectUrls[resp.redirectUrls.length - 1];
}
} catch (error) {
if (useHttp) {
return undefined;
}
logDebug('getServerUrlAfterRedirect error', url, error);
return {error};
}
return sanitizeUrl(url, useHttp);
return {url: sanitizeUrl(url, useHttp)};
}
export function stripTrailingSlashes(url = '') {

View file

@ -46,8 +46,14 @@
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsLocalNetworking</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>NSAppleMusicUsageDescription</key>
<string>Enabling access to your media library means you can attach files from your media library to your messages in $(PRODUCT_NAME).</string>

2
package-lock.json generated
View file

@ -6,7 +6,7 @@
"packages": {
"": {
"name": "mattermost-mobile",
"version": "2.14.0",
"version": "2.15.0",
"hasInstallScript": true,
"license": "Apache 2.0",
"dependencies": {