如何解决如何配置RabbitMQ客户端使用SSL?
我正在使用 Micronaut 的 RabbitMQ 包连接到我的 RabbitMQ 服务器(请参阅此处:https://micronaut-projects.github.io/micronaut-rabbitmq/latest)。 我可以轻松地将服务器配置为侦听 SSL 端口,但是我无法理解如何将我的客户端配置为通过 SSL 进行连接。
我发现的所有示例都手动创建了连接,但在我的例子中,连接是由 Micronaut 在后台创建的,我想仅通过设置属性来配置它。
在 this section of the configuration 中列出了所有 rabbitmq 属性,但是唯一与 ssl 相关的是 ssl-context-factory
并且没有提供任何解释或示例。
我本以为 this answer for Spring 之类的东西,其中(据说)存在一个 spring.rabbitmq.ssl.enabled
属性,可以打开 SSL 连接。
- 有没有类似 micronaut 的东西?
- 如果不是,那
ssl-context-factory
是正确的配置属性吗?你是如何设置的? - 加分项:我应该如何配置密钥库来验证服务器证书? Micronaut 会自动为兔子连接使用
micronaut.ssl.key-store.*
值吗?
最后一点:我不对服务器进行 mTLS/客户端身份验证感兴趣。我只是希望我的客户端使用加密的 SSL 连接与服务器通话。所以客户端不需要任何证书,它只需要验证服务器证书。
解决方法
我相信我找到了答案,尽管我不确定它是否是最好的。
Micronaut RabbitMQ 支持允许为连接指定 uri 而不是主机和端口。因此可以指定 const EditableCell = {
template: `
<div class="editable-cell">
<div v-if="editable" class="editable-cell-input-wrapper">
<a-input :value="value" @change="handleChange" @pressEnter="check" /><a-icon
type="check"
class="editable-cell-icon-check"
@click="check"
/>
</div>
<div v-else class="editable-cell-text-wrapper">
{{ value || ' ' }}
<a-icon type="edit" class="editable-cell-icon" @click="edit" />
</div>
</div>
`,props: {
text: String,},data() {
return {
value: this.text,editable: false,};
},methods: {
handleChange(e) {
const value = e.target.value;
this.value = value;
},check() {
this.editable = false;
this.$emit("change",this.value);
},edit() {
this.editable = true;
},};
const Editcell = {
template: `
<div class="editable-cell">
<div v-if="editable" class="editable-cell-input-wrapper">
<a-input :value="value" @change="handleChange2" @pressEnter="check2" /><a-icon
type="check"
class="editable-cell-icon-check"
@click="check2"
/>
</div>
<div v-else class="editable-cell-text-wrapper">
{{ value || ' ' }}
<a-icon type="edit" class="editable-cell-icon" @click="edit2" />
</div>
</div>
`,data2() {
return {
value: this.text,methods: {
handleChange2(e) {
const value = e.target.value;
this.value = value;
},check2() {
this.editable = false;
this.$emit("change",edit2() {
this.editable = true;
},};
export default {
components: {
EditableCell,Editcell,data() {
return {
dataSource: [
{
key: "0",type: "Gender",item: "Are you ",nestedData: [
{ key: 0,choice: "Man" },{ key: 1,choice: "Woman" },],{
key: "1",type: "Contract",item: "What is your contract ?",choice: "nested 11111" },choice: "nested 122222" },count: 2,columns: [
{
title: "Type",dataIndex: "type",width: "30%",scopedSlots: { customRender: "type" },{
title: "Item",dataIndex: "item",scopedSlots: { customRender: "item" },methods: {
onCellChange(key,dataIndex,value) {
const dataSource = [...this.dataSource];
console.log(key);
const target = dataSource.find((item) => item.key === key);
if (target) {
target[dataIndex] = value;
this.dataSource = dataSource;
}
},onCellChange2(key,value) {
const dataSource = [...this.dataSource];
const nested = dataSource.find((item) => item.key === key);
const target = nested.nestedData.findIndex((p) => p.key === 0);
if (target) {
target[dataIndex] = value;
this.dataSource = dataSource;
}
},handleAdd() {
const { count,dataSource } = this;
const newData = {
key: count,type: "TYPE",item: "ITEM",};
this.dataSource = [...dataSource,newData];
this.count = count + 1;
},computed: {
rowSelection() {
return {
onChange: (selectedRowKeys,selectedRows) => {
console.log(
`selectedRowKeys: ${selectedRowKeys}`,"selectedRows: ",selectedRows
);
},getCheckboxProps: (record) => ({
props: {
disabled: record.name === "Disabled User",// Column configuration not to be checked
name: record.name,}),};
},};
并且它应该通过 SSL 连接。似乎不幸的是,如果您使用 SSL,则无法使用主机和端口属性。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。