Skip to content

Commit

Permalink
Merge pull request #1 from zzhxiaofeng/https
Browse files Browse the repository at this point in the history
update for adding HTTPS support
  • Loading branch information
jongio authored Mar 4, 2020
2 parents a58ed22 + 7c8d7da commit cf0cb61
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ Or customize multi storage accounts and each has 2 keys:
set AZURITE_ACCOUNTS="account1:key1:key2;account2:key1:key2"
```

### HTTP Setup
### HTTPS Setup

You can generate a local certificate for 127.0.0.1 with `mkcert`. See the mkcert GitHub repo for [installation instructions](https://github.com/FiloSottile/mkcert), and then run the following commands.

Expand Down Expand Up @@ -427,9 +427,9 @@ unable to verify the first certificate.
Follow these steps to add the HTTPS endpoints to Storage Explorer:

1. Right click on Local & Attached->Storage Accounts and select "Connect to Azure Storage...".
1. Select "Use a connection string" and click Next.
1. Enter a name, i.e https.
1. Enter the HTTPS connection string from the previous section of this document and click Next.
2. Select "Use a connection string" and click Next.
3. Enter a name, i.e https.
4. Enter the HTTPS connection string from the previous section of this document and click Next.

You can now explore the Azurite HTTPS endpoints with Storage Explorer.

Expand Down
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@
"default": false,
"description": "Enable loose mode which ignores unsupported headers and parameters"
},
"azurite.cert": {
"type": "string",
"default": "",
"description": "Locally-trusted certificate"
},
"azurite.key": {
"type": "string",
"default": "",
"description": "Locally-trusted key file"
},
"azurite.location": {
"type": "string",
"description": "Workspace location folder path, by default Visual Studio Code current opened folder"
Expand Down Expand Up @@ -228,4 +238,4 @@
"url": "https://github.com/azure/azurite/issues"
},
"homepage": "https://github.com/azure/azurite#readme"
}
}
6 changes: 4 additions & 2 deletions src/blob/BlobRequestListenerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ export default class BlobRequestListenerFactory
private readonly accountDataStore: IAccountDataStore,
private readonly enableAccessLog: boolean,
private readonly accessLogWriteStream?: NodeJS.WritableStream,
private readonly loose?: boolean
) {}
private readonly loose?: boolean,
private readonly cert?: string,
private readonly key?: string
) { }

public createRequestListener(): RequestListener {
const app = express().disable("x-powered-by");
Expand Down
8 changes: 6 additions & 2 deletions src/blob/SqlBlobConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export default class SqlBlobConfiguration extends ConfigurationBase {
accessLogWriteStream?: NodeJS.WritableStream,
enableDebugLog: boolean = DEFAULT_ENABLE_DEBUG_LOG,
debugLogFilePath?: string,
loose: boolean = false
loose: boolean = false,
cert: string = "",
key: string = ""
) {
super(
host,
Expand All @@ -38,7 +40,9 @@ export default class SqlBlobConfiguration extends ConfigurationBase {
accessLogWriteStream,
enableDebugLog,
debugLogFilePath,
loose
loose,
cert,
key
);
}
}
4 changes: 3 additions & 1 deletion src/blob/SqlBlobServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export default class SqlBlobServer extends ServerBase {
accountDataStore,
configuration.enableAccessLog, // Access log includes every handled HTTP request
configuration.accessLogWriteStream,
configuration.loose
configuration.loose,
configuration.cert,
configuration.key
);

super(host, port, httpServer, requestListenerFactory, configuration);
Expand Down
2 changes: 1 addition & 1 deletion src/common/ServerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default abstract class ServerBase implements ICleaner {
const address = this.httpServer.address();
const protocol = `http${this.config.hasCert() ? "s" : ""}://`;

if (typeof address === "string" || address === null) {
if (typeof address === "string") {
return protocol + address;
} else if (address === null) {
return "";
Expand Down

0 comments on commit cf0cb61

Please sign in to comment.