Skip to content

Commit

Permalink
fix(connections): support TLS/SSL one-way authentication(#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysfscream committed Jan 3, 2020
1 parent 141bfd7 commit 643cf03
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
13 changes: 3 additions & 10 deletions src/utils/getFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@ import fs from 'fs'
import path from 'path'
import { SSLPath, SSLContent } from '@/views/connections/types'

export const getCAFile = () => {
// igonre
}

export const getSSLFile = (sslPath: SSLPath): SSLContent | undefined => {
const { ca, cert, key } = sslPath
if (ca === '' && cert === '' && key === '') {
return undefined
}
const res: SSLContent = {
ca: fs.readFileSync(path.join(ca), 'utf-8'),
cert: fs.readFileSync(path.join(cert), 'utf-8'),
key: fs.readFileSync(path.join(key), 'utf-8'),
ca: ca !== '' ? [fs.readFileSync(path.join(ca), 'utf-8')] : undefined,
cert: cert !== '' ? fs.readFileSync(path.join(cert), 'utf-8') : undefined,
key: key !== '' ? fs.readFileSync(path.join(key), 'utf-8') : undefined,
}
return res
}
Expand Down
4 changes: 1 addition & 3 deletions src/views/connections/ConnectionForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<el-col :span="22">
<el-form-item label-width="93px" :label="$t('connections.certType')" prop="certType">
<el-radio-group v-model="record.certType">
<el-radio label="ca">CA signed server</el-radio>
<el-radio label="server">CA signed server</el-radio>
<el-radio label="self">Self signed</el-radio>
</el-radio-group>
</el-form-item>
Expand Down Expand Up @@ -259,8 +259,6 @@ export default class ConnectionCreate extends Vue {
port: [{ required: true, message: this.$t('common.inputRequired') }],
certType: [{ required: true, message: this.$t('common.selectRequired') }],
ca: [{ required: true, message: this.$t('common.inputRequired') }],
cert: [{ required: true, message: this.$t('common.inputRequired') }],
key: [{ required: true, message: this.$t('common.inputRequired') }],
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/connections/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface ConnectionModel extends SSLPath {
username: string,
password: string,
path: string,
certType?: '' | 'ca' | 'self',
certType?: '' | 'server' | 'self',
ssl: boolean,
mqttVersion: '3.1.1' | '5.0',
unreadMessageCount: number,
Expand Down

0 comments on commit 643cf03

Please sign in to comment.